feat: initial release
This commit is contained in:
commit
034cf44a1e
12 changed files with 1077 additions and 0 deletions
27
src/wutta_corepos/__init__.py
Normal file
27
src/wutta_corepos/__init__.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Wutta-COREPOS -- Wutta Framework integration for CORE-POS
|
||||
# Copyright © 2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Wutta Framework.
|
||||
#
|
||||
# Wutta Framework is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option) any
|
||||
# later version.
|
||||
#
|
||||
# Wutta Framework is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Wutta Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
Wutta-COREPOS -- Wutta Framework integration for CORE-POS
|
||||
"""
|
||||
|
||||
from ._version import __version__
|
6
src/wutta_corepos/_version.py
Normal file
6
src/wutta_corepos/_version.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
|
||||
from importlib.metadata import version
|
||||
|
||||
|
||||
__version__ = version('Wutta-COREPOS')
|
44
src/wutta_corepos/app.py
Normal file
44
src/wutta_corepos/app.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Wutta-COREPOS -- Wutta Framework integration for CORE-POS
|
||||
# Copyright © 2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Wutta Framework.
|
||||
#
|
||||
# Wutta Framework is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option) any
|
||||
# later version.
|
||||
#
|
||||
# Wutta Framework is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Wutta Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
App Provider
|
||||
"""
|
||||
|
||||
from wuttjamaican.app import AppProvider
|
||||
|
||||
|
||||
class WuttaCoreposAppProvider(AppProvider):
|
||||
"""
|
||||
The :term:`app provider` for Wutta-COREPOS.
|
||||
|
||||
This adds the :meth:`get_corepos_handler()` method for the
|
||||
:term:`app handler`.
|
||||
"""
|
||||
|
||||
def get_corepos_handler(self, **kwargs):
|
||||
if not hasattr(self, 'corepos_handler'):
|
||||
spec = self.config.get(f'{self.appname}.corepos_handler',
|
||||
default='wutta_corepos.handler:CoreposHandler')
|
||||
factory = self.app.load_object(spec)
|
||||
self.corepos_handler = factory(self.config, **kwargs)
|
||||
return self.corepos_handler
|
102
src/wutta_corepos/conf.py
Normal file
102
src/wutta_corepos/conf.py
Normal file
|
@ -0,0 +1,102 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Wutta-COREPOS -- Wutta Framework integration for CORE-POS
|
||||
# Copyright © 2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Wutta Framework.
|
||||
#
|
||||
# Wutta Framework is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option) any
|
||||
# later version.
|
||||
#
|
||||
# Wutta Framework is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Wutta Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
App Configuration
|
||||
"""
|
||||
|
||||
from wuttjamaican.conf import WuttaConfigExtension
|
||||
from wuttjamaican.db.conf import get_engines
|
||||
|
||||
|
||||
class WuttaCoreposConfigExtension(WuttaConfigExtension):
|
||||
"""
|
||||
App :term:`config extension` for Wutta-COREPOS.
|
||||
|
||||
This does some CORE DB connection setup based on config. It will
|
||||
create three sets of DB engines, and establish one primary engine
|
||||
for each set. The sets correspond to CORE Office DB types:
|
||||
|
||||
* ``office_op`` (default name ``core_op``)
|
||||
* ``office_trans`` (default name ``core_trans``)
|
||||
* ``office_arch`` (default name ``trans_archive``)
|
||||
|
||||
The config object will be given the following attributes:
|
||||
|
||||
.. data:: core_office_op_engine
|
||||
|
||||
Primary engine for the ``office_op`` DB. May be null if no
|
||||
config is found.
|
||||
|
||||
.. data:: core_office_op_engines
|
||||
|
||||
Dict of ``office_op`` DB engines. May be empty if no config is
|
||||
found; otherwise there should at least be a ``default`` key
|
||||
defined, corresonding to :data:`core_office_op_engine`.
|
||||
|
||||
.. data:: core_office_trans_engine
|
||||
|
||||
Primary engine for the ``office_trans`` DB. May be null if no
|
||||
config is found.
|
||||
|
||||
.. data:: core_office_trans_engines
|
||||
|
||||
Dict of ``office_trans`` DB engines. May be empty if no config
|
||||
is found; otherwise there should at least be a ``default`` key
|
||||
defined, corresonding to :data:`core_office_trans_engine`.
|
||||
|
||||
.. data:: core_office_arch_engine
|
||||
|
||||
Primary engine for the ``office_arch`` DB. May be null if no
|
||||
config is found.
|
||||
|
||||
.. data:: core_office_arch_engines
|
||||
|
||||
Dict of ``office_arch`` DB engines. May be empty if no config
|
||||
is found; otherwise there should at least be a ``default`` key
|
||||
defined, corresonding to :data:`core_office_arch_engine`.
|
||||
"""
|
||||
key = 'wutta_corepos'
|
||||
|
||||
def configure(self, config):
|
||||
""" """
|
||||
|
||||
# office_op
|
||||
from corepos.db.office_op import Session
|
||||
engines = get_engines(config, 'corepos.db.office_op')
|
||||
config.core_office_op_engines = engines
|
||||
config.core_office_op_engine = engines.get('default')
|
||||
Session.configure(bind=config.core_office_op_engine)
|
||||
|
||||
# office_trans
|
||||
from corepos.db.office_trans import Session
|
||||
engines = get_engines(config, 'corepos.db.office_trans')
|
||||
config.core_office_trans_engines = engines
|
||||
config.core_office_trans_engine = engines.get('default')
|
||||
Session.configure(bind=config.core_office_trans_engine)
|
||||
|
||||
# office_arch
|
||||
from corepos.db.office_arch import Session
|
||||
engines = get_engines(config, 'corepos.db.office_arch')
|
||||
config.core_office_arch_engines = engines
|
||||
config.core_office_arch_engine = engines.get('default')
|
||||
Session.configure(bind=config.core_office_arch_engine)
|
100
src/wutta_corepos/handler.py
Normal file
100
src/wutta_corepos/handler.py
Normal file
|
@ -0,0 +1,100 @@
|
|||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Wutta-COREPOS -- Wutta Framework integration for CORE-POS
|
||||
# Copyright © 2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Wutta Framework.
|
||||
#
|
||||
# Wutta Framework is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option) any
|
||||
# later version.
|
||||
#
|
||||
# Wutta Framework is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# Wutta Framework. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
"""
|
||||
CORE-POS Handler
|
||||
"""
|
||||
|
||||
from wuttjamaican.app import GenericHandler
|
||||
|
||||
|
||||
class CoreposHandler(GenericHandler):
|
||||
"""
|
||||
Base class and default implementation for the CORE-POS integration
|
||||
:term:`handler`.
|
||||
"""
|
||||
|
||||
def get_office_url(self, require=False):
|
||||
"""
|
||||
Returns the base URL for the CORE Office web app.
|
||||
|
||||
Note that the return value is stripped of final slash.
|
||||
"""
|
||||
url = self.config.get('corepos.office.url', require=require)
|
||||
if url:
|
||||
return url.rstrip('/')
|
||||
|
||||
def get_office_department_url(
|
||||
self,
|
||||
number,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
"""
|
||||
Returns the CORE Office URL for a Department.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
if office_url:
|
||||
return f'{office_url}/item/departments/DepartmentEditor.php?did={number}'
|
||||
|
||||
def get_office_likecode_url(
|
||||
self,
|
||||
id,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
"""
|
||||
Returns the CORE Office URL for a Like Code.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
if office_url:
|
||||
return f'{office_url}/item/likecodes/LikeCodeEditor.php?start={id}'
|
||||
|
||||
def get_office_product_url(
|
||||
self,
|
||||
upc,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
"""
|
||||
Returns the CORE Office URL for a Product.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
if office_url:
|
||||
return f'{office_url}/item/ItemEditorPage.php?searchupc={upc}'
|
||||
|
||||
def get_office_vendor_url(
|
||||
self,
|
||||
id,
|
||||
office_url=None,
|
||||
require=False,
|
||||
**kwargs):
|
||||
"""
|
||||
Returns the CORE Office URL for a Vendor.
|
||||
"""
|
||||
if not office_url:
|
||||
office_url = self.get_office_url(require=require)
|
||||
if office_url:
|
||||
return f'{office_url}/item/vendors/VendorIndexPage.php?vid={id}'
|
Loading…
Add table
Add a link
Reference in a new issue