Compare commits
16 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7249598b35 | ||
![]() |
3514b47776 | ||
![]() |
494cae2433 | ||
![]() |
06d1ada3fd | ||
![]() |
827927355d | ||
![]() |
6a26de3622 | ||
![]() |
5e60a9e0af | ||
![]() |
1c5e3296d7 | ||
![]() |
25d1eaa816 | ||
![]() |
a7ff4e4ffc | ||
![]() |
4a3f4cf829 | ||
![]() |
af7deee26b | ||
![]() |
4bb35b50f4 | ||
![]() |
eae58f97ad | ||
![]() |
5b4d4729eb | ||
![]() |
1c39dbd881 |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
*~
|
||||
*.pyc
|
||||
dist/
|
||||
tailbone_corepos.egg-info/
|
||||
|
|
32
CHANGELOG.md
32
CHANGELOG.md
|
@ -5,6 +5,38 @@ All notable changes to tailbone-corepos will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## v0.3.2 (2024-11-18)
|
||||
|
||||
### Fix
|
||||
|
||||
- add startup workaround for CORE model imports, to avoid error
|
||||
|
||||
## v0.3.1 (2024-08-18)
|
||||
|
||||
### Fix
|
||||
|
||||
- refactory grid usage per wuttaweb
|
||||
|
||||
## v0.3.0 (2024-08-06)
|
||||
|
||||
### Feat
|
||||
|
||||
- add view for CORE Custom Receipt Lines (`op.customReceipt`)
|
||||
|
||||
## v0.2.1 (2024-07-05)
|
||||
|
||||
### Fix
|
||||
|
||||
- add link to CORE for profile employee tab
|
||||
- link to CORE when viewing profile member tab
|
||||
- remove dependency for `six` package
|
||||
|
||||
## v0.2.0 (2024-06-10)
|
||||
|
||||
### Feat
|
||||
|
||||
- switch from setup.cfg to pyproject.toml + hatchling
|
||||
|
||||
## [0.1.39] - 2024-06-03
|
||||
### Changed
|
||||
- Use standard xref buttons for CORE record views.
|
||||
|
|
12
README.md
Normal file
12
README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
# tailbone-corepos
|
||||
|
||||
Rattail is a retail software framework, released under the GNU General
|
||||
Public License.
|
||||
|
||||
This package contains software interfaces for the [CORE
|
||||
POS](https://www.core-pos.com/) system, which is open source and
|
||||
freely available.
|
||||
|
||||
Please see Rattail's [home page](https://rattailproject.org/) for more
|
||||
information.
|
15
README.rst
15
README.rst
|
@ -1,15 +0,0 @@
|
|||
|
||||
tailbone-corepos
|
||||
================
|
||||
|
||||
Rattail is a retail software framework, released under the GNU General Public
|
||||
License.
|
||||
|
||||
This package contains software interfaces for the `CORE POS`_ system, which is
|
||||
open source and freely available.
|
||||
|
||||
.. _`CORE POS`: https://www.core-pos.com/
|
||||
|
||||
Please see Rattail's `home page`_ for more information.
|
||||
|
||||
.. _`home page`: https://rattailproject.org/
|
49
pyproject.toml
Normal file
49
pyproject.toml
Normal file
|
@ -0,0 +1,49 @@
|
|||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
|
||||
[project]
|
||||
name = "tailbone-corepos"
|
||||
version = "0.3.2"
|
||||
description = "Tailbone interfaces for CORE POS"
|
||||
readme = "README.md"
|
||||
authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]
|
||||
license = {text = "GNU GPL v3+"}
|
||||
classifiers = [
|
||||
"Development Status :: 4 - Beta",
|
||||
"Environment :: Web Environment",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
|
||||
"Natural Language :: English",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Topic :: Office/Business",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
|
||||
dependencies = [
|
||||
"rattail",
|
||||
"rattail-corepos",
|
||||
"Tailbone",
|
||||
]
|
||||
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://rattailproject.org"
|
||||
Repository = "https://forgejo.wuttaproject.org/rattail/tailbone-corepos"
|
||||
Issues = "https://forgejo.wuttaproject.org/rattail/tailbone-corepos/issues"
|
||||
Changelog = "https://forgejo.wuttaproject.org/rattail/tailbone-corepos/src/branch/master/CHANGELOG.md"
|
||||
|
||||
|
||||
[project.entry-points."tailbone.providers"]
|
||||
tailbone_corepos = "tailbone_corepos.provider:TailboneCorePosProvider"
|
||||
|
||||
|
||||
[tool.commitizen]
|
||||
version_provider = "pep621"
|
||||
tag_format = "v$version"
|
||||
update_changelog_on_bump = true
|
41
setup.cfg
41
setup.cfg
|
@ -1,41 +0,0 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
[metadata]
|
||||
name = tailbone-corepos
|
||||
version = attr: tailbone_corepos.__version__
|
||||
author = Lance Edgar
|
||||
author_email = lance@edbob.org
|
||||
url = https://rattailproject.org/
|
||||
license = GNU GPL v3
|
||||
description = Tailbone interfaces for CORE POS
|
||||
long_description = file: README.rst
|
||||
classifiers =
|
||||
Development Status :: 4 - Beta
|
||||
Environment :: Web Environment
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
||||
Natural Language :: English
|
||||
Operating System :: OS Independent
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.5
|
||||
Topic :: Office/Business
|
||||
Topic :: Software Development :: Libraries :: Python Modules
|
||||
|
||||
|
||||
[options]
|
||||
install_requires =
|
||||
rattail
|
||||
rattail-corepos
|
||||
six
|
||||
Tailbone
|
||||
|
||||
packages = find:
|
||||
include_package_data = True
|
||||
zip_safe = False
|
||||
|
||||
|
||||
[options.entry_points]
|
||||
|
||||
tailbone.providers =
|
||||
tailbone_corepos = tailbone_corepos.provider:TailboneCorePosProvider
|
|
@ -1,3 +1,6 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
__version__ = '0.1.39'
|
||||
from importlib.metadata import version
|
||||
|
||||
|
||||
__version__ = version('tailbone-corepos')
|
||||
|
|
|
@ -71,6 +71,11 @@ def make_corepos_menu(request):
|
|||
'route': 'corepos.member_types',
|
||||
'perm': 'corepos.member_types.list',
|
||||
},
|
||||
{
|
||||
'title': "Member Contact Preferences",
|
||||
'route': 'corepos.member_contact_prefs',
|
||||
'perm': 'corepos.member_contact_prefs.list',
|
||||
},
|
||||
{
|
||||
'title': "Employees",
|
||||
'route': 'corepos.employees',
|
||||
|
@ -202,6 +207,11 @@ def make_corepos_menu(request):
|
|||
'route': 'corepos.tenders',
|
||||
'perm': 'corepos.tenders.list',
|
||||
},
|
||||
{
|
||||
'title': "Custom Receipt Lines",
|
||||
'route': 'corepos.custom_receipt_lines',
|
||||
'perm': 'corepos.custom_receipt_lines.list',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
# Copyright © 2010-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -24,6 +24,7 @@
|
|||
Tailbone Provider for CORE-POS Integration
|
||||
"""
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||
from zope.sqlalchemy import register
|
||||
|
||||
|
@ -71,6 +72,37 @@ class TailboneCorePosProvider(TailboneProvider):
|
|||
register(Session)
|
||||
ExtraCoreTransArchiveSessions[key] = Session
|
||||
|
||||
# must import all sqlalchemy models before things get rolling,
|
||||
# otherwise can have errors about continuum TransactionMeta class
|
||||
# not yet mapped, when relevant pages are first requested...
|
||||
# cf. https://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/database/sqlalchemy.html#importing-all-sqlalchemy-models
|
||||
# hat tip to https://stackoverflow.com/a/59241485
|
||||
if rattail_config.core_office_op_engine:
|
||||
app = rattail_config.get_app()
|
||||
corepos = app.get_corepos_handler()
|
||||
|
||||
# nb. use fake db to avoid true cxn errors, since the only
|
||||
# point of this is to load the models
|
||||
engine = sa.create_engine('sqlite://')
|
||||
|
||||
# office_op
|
||||
core_model = corepos.get_model_office_op()
|
||||
core_session = corepos.make_session_office_op(bind=engine)
|
||||
try:
|
||||
core_session.query(core_model.Store).first()
|
||||
except sa.exc.OperationalError:
|
||||
pass
|
||||
core_session.close()
|
||||
|
||||
# office_trans
|
||||
core_model = corepos.get_model_office_trans()
|
||||
core_session = corepos.make_session_office_trans(bind=engine)
|
||||
try:
|
||||
core_session.query(core_model.TransactionDetail).first()
|
||||
except sa.exc.OperationalError:
|
||||
pass
|
||||
core_session.close()
|
||||
|
||||
def get_provided_views(self):
|
||||
return {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
# Copyright © 2010-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -48,6 +48,7 @@ def defaults(config, **kwargs):
|
|||
config.include(mod('tailbone_corepos.views.corepos.customers'))
|
||||
config.include(mod('tailbone_corepos.views.corepos.employees'))
|
||||
config.include(mod('tailbone_corepos.views.corepos.coupons'))
|
||||
config.include(mod('tailbone_corepos.views.corepos.receipts'))
|
||||
config.include(mod('tailbone_corepos.views.corepos.tenders'))
|
||||
config.include(mod('tailbone_corepos.views.corepos.stockpurchases'))
|
||||
config.include(mod('tailbone_corepos.views.corepos.taxrates'))
|
||||
|
|
|
@ -125,7 +125,8 @@ class UserGroupView(CoreOfficeMasterView):
|
|||
permission_prefix = self.get_permission_prefix()
|
||||
factory = self.get_grid_factory()
|
||||
g = factory(
|
||||
key='{}.users'.format(route_prefix),
|
||||
self.request,
|
||||
key=f'{route_prefix}.users',
|
||||
data=[],
|
||||
columns=[
|
||||
'username',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
# Copyright © 2010-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -26,8 +26,8 @@ CORE-POS member views
|
|||
|
||||
from sqlalchemy import orm
|
||||
|
||||
from corepos.db.office_op import model as corepos
|
||||
from corepos.db.office_trans import model as coretrans
|
||||
from corepos.db.office_op.model import MemberType, MemberContactPreference, MemberInfo
|
||||
from corepos.db.office_trans.model import StockPurchase
|
||||
|
||||
from webhelpers2.html import HTML, tags
|
||||
|
||||
|
@ -39,7 +39,7 @@ class MemberTypeView(CoreOfficeMasterView):
|
|||
"""
|
||||
Master view for member types
|
||||
"""
|
||||
model_class = corepos.MemberType
|
||||
model_class = MemberType
|
||||
model_title = "CORE-POS Member Type"
|
||||
url_prefix = '/core-pos/member-types'
|
||||
route_prefix = 'corepos.member_types'
|
||||
|
@ -56,11 +56,29 @@ class MemberTypeView(CoreOfficeMasterView):
|
|||
g.set_link('description')
|
||||
|
||||
|
||||
class MemberContactPreferenceView(CoreOfficeMasterView):
|
||||
"""
|
||||
Master view for member contact preferences
|
||||
"""
|
||||
model_class = MemberContactPreference
|
||||
model_title = "CORE-POS Member Contact Preference"
|
||||
url_prefix = '/core-pos/member-contact-prefs'
|
||||
route_prefix = 'corepos.member_contact_prefs'
|
||||
|
||||
def configure_grid(self, g):
|
||||
super().configure_grid(g)
|
||||
|
||||
g.set_sort_defaults('id')
|
||||
g.set_link('id')
|
||||
|
||||
g.set_link('description')
|
||||
|
||||
|
||||
class MemberView(CoreOfficeMasterView):
|
||||
"""
|
||||
Master view for members
|
||||
"""
|
||||
model_class = corepos.MemberInfo
|
||||
model_class = MemberInfo
|
||||
model_title = "CORE-POS Member (classic)"
|
||||
model_title_plural = "CORE-POS Members (classic)"
|
||||
url_prefix = '/core-pos/members'
|
||||
|
@ -107,7 +125,7 @@ class MemberView(CoreOfficeMasterView):
|
|||
]
|
||||
|
||||
has_rows = True
|
||||
model_row_class = coretrans.StockPurchase
|
||||
model_row_class = StockPurchase
|
||||
rows_title = "Stock Purchases"
|
||||
|
||||
row_labels = {
|
||||
|
@ -196,6 +214,9 @@ class MemberView(CoreOfficeMasterView):
|
|||
return tags.link_to(text, url)
|
||||
|
||||
def render_equity_live_balance(self, member, field):
|
||||
app = self.get_rattail_app()
|
||||
corepos = app.get_corepos_handler()
|
||||
coretrans = corepos.get_model_office_trans()
|
||||
try:
|
||||
balance = CoreTransSession.query(coretrans.EquityLiveBalance)\
|
||||
.filter(coretrans.EquityLiveBalance.member_number == member.card_number)\
|
||||
|
@ -214,11 +235,14 @@ class MemberView(CoreOfficeMasterView):
|
|||
return [self.make_xref_button(url=url, text="View in CORE Office")]
|
||||
|
||||
def get_row_data(self, member):
|
||||
app = self.get_rattail_app()
|
||||
corepos = app.get_corepos_handler()
|
||||
coretrans = corepos.get_model_office_trans()
|
||||
return CoreTransSession.query(coretrans.StockPurchase)\
|
||||
.filter(coretrans.StockPurchase.card_number == member.card_number)
|
||||
|
||||
def get_parent(self, stock_purchase):
|
||||
return self.Session.get(corepos.MemberInfo, stock_purchase.card_number)
|
||||
return self.Session.get(MemberInfo, stock_purchase.card_number)
|
||||
|
||||
def configure_row_grid(self, g):
|
||||
super().configure_row_grid(g)
|
||||
|
@ -241,6 +265,9 @@ def defaults(config, **kwargs):
|
|||
MemberTypeView = kwargs.get('MemberTypeView', base['MemberTypeView'])
|
||||
MemberTypeView.defaults(config)
|
||||
|
||||
MemberContactPreferenceView = kwargs.get('MemberContactPreferenceView', base['MemberContactPreferenceView'])
|
||||
MemberContactPreferenceView.defaults(config)
|
||||
|
||||
MemberView = kwargs.get('MemberView', base['MemberView'])
|
||||
MemberView.defaults(config)
|
||||
|
||||
|
|
|
@ -248,7 +248,8 @@ class ProductView(CoreOfficeMasterView):
|
|||
|
||||
factory = self.get_grid_factory()
|
||||
g = factory(
|
||||
key='{}.vendor_items'.format(route_prefix),
|
||||
self.request,
|
||||
key=f'{route_prefix}.vendor_items',
|
||||
data=[],
|
||||
columns=[
|
||||
'vendor_name',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
# Copyright © 2010-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -20,7 +20,31 @@
|
|||
# Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
CORE POS receipt views
|
||||
"""
|
||||
|
||||
from setuptools import setup
|
||||
from corepos.db.office_op.model import CustomReceiptLine
|
||||
|
||||
setup()
|
||||
from .master import CoreOfficeMasterView
|
||||
|
||||
|
||||
class CustomReceiptLineView(CoreOfficeMasterView):
|
||||
"""
|
||||
Master view for custom receipt text
|
||||
"""
|
||||
model_class = CustomReceiptLine
|
||||
model_title = "CORE-POS Custom Receipt Line"
|
||||
route_prefix = 'corepos.custom_receipt_lines'
|
||||
url_prefix = '/core-pos/custom-receipt-lines'
|
||||
|
||||
|
||||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
||||
CustomReceiptLineView = kwargs.get('CustomReceiptLineView', base['CustomReceiptLineView'])
|
||||
CustomReceiptLineView.defaults(config)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
defaults(config)
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
# Copyright © 2010-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -68,6 +68,30 @@ class PersonViewSupplement(ViewSupplement):
|
|||
|
||||
return context
|
||||
|
||||
def get_context_for_member(self, member, context):
|
||||
|
||||
if member.corepos_card_number:
|
||||
app = self.get_rattail_app()
|
||||
corepos = app.get_corepos_handler()
|
||||
url = corepos.get_office_member_url(member.corepos_card_number)
|
||||
if url:
|
||||
context['external_links'].append({'label': "View in CORE Office",
|
||||
'url': url})
|
||||
|
||||
return context
|
||||
|
||||
def get_context_for_employee(self, employee, context):
|
||||
|
||||
if employee.corepos_number:
|
||||
app = self.get_rattail_app()
|
||||
corepos = app.get_corepos_handler()
|
||||
url = corepos.get_office_employee_url(employee.corepos_number)
|
||||
if url:
|
||||
context['external_links'].append({'label': "View in CORE Office",
|
||||
'url': url})
|
||||
|
||||
return context
|
||||
|
||||
def get_member_xref_buttons(self, person):
|
||||
buttons = OrderedDict()
|
||||
app = self.get_rattail_app()
|
||||
|
|
20
tasks.py
20
tasks.py
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2019 Lance Edgar
|
||||
# Copyright © 2010-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -25,13 +25,24 @@ Tasks for tailbone-corepos
|
|||
"""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from invoke import task
|
||||
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
exec(open(os.path.join(here, 'tailbone_corepos', '_version.py')).read())
|
||||
__version__ = None
|
||||
pattern = re.compile(r'^version = "(\d+\.\d+\.\d+)"$')
|
||||
with open(os.path.join(here, 'pyproject.toml'), 'rt') as f:
|
||||
for line in f:
|
||||
line = line.rstrip('\n')
|
||||
match = pattern.match(line)
|
||||
if match:
|
||||
__version__ = match.group(1)
|
||||
break
|
||||
if not __version__:
|
||||
raise RuntimeError("could not parse version!")
|
||||
|
||||
|
||||
@task
|
||||
|
@ -39,7 +50,8 @@ def release(c):
|
|||
"""
|
||||
Release a new version of 'tailbone-corepos'.
|
||||
"""
|
||||
shutil.rmtree('tailbone_corepos.egg-info')
|
||||
c.run('python setup.py sdist --formats=gztar')
|
||||
if os.path.exists('tailbone_corepos.egg-info'):
|
||||
shutil.rmtree('tailbone_corepos.egg-info')
|
||||
c.run('python -m build --sdist')
|
||||
filename = f'tailbone_corepos-{__version__}.tar.gz'
|
||||
c.run('twine upload dist/{}'.format(filename))
|
||||
|
|
Loading…
Reference in a new issue