From ab56a35acc3c08ee6d9992dee59086d8654c987c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 14 Jan 2025 20:20:41 -0600 Subject: [PATCH 1/3] fix: add more enums for batch discount type, editor UI also fix column type for editor UI --- corepos/db/office_op/model.py | 2 +- corepos/enum.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index 16bbc57..68627c0 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -1646,7 +1646,7 @@ class BatchType(Base): special_order_eligible = sa.Column('specialOrderEligible', sa.Boolean(), nullable=True, default=True) - editor_ui = sa.Column('editorUI', sa.Boolean(), nullable=True, default=True) + editor_ui = sa.Column('editorUI', sa.SmallInteger(), nullable=True, default=True) allow_single_store = sa.Column('allowSingleStore', sa.Boolean(), nullable=True, default=False) diff --git a/corepos/enum.py b/corepos/enum.py index 28e33ea..93780c3 100644 --- a/corepos/enum.py +++ b/corepos/enum.py @@ -34,14 +34,33 @@ class CoreDbType(str, Enum): office_arch = 'office_arch' +BATCH_DISCOUNT_TYPE_TRACKING = -1 BATCH_DISCOUNT_TYPE_PRICE_CHANGE = 0 BATCH_DISCOUNT_TYPE_SALE_EVERYONE = 1 BATCH_DISCOUNT_TYPE_SALE_RESTRICTED = 2 +BATCH_DISCOUNT_TYPE_SLIDING_PERCENT = 3 +BATCH_DISCOUNT_TYPE_SLIDING_AMOUNT = 5 BATCH_DISCOUNT_TYPE = OrderedDict([ - (BATCH_DISCOUNT_TYPE_PRICE_CHANGE, "Price Change"), + (BATCH_DISCOUNT_TYPE_PRICE_CHANGE, "None (Change regular price)"), (BATCH_DISCOUNT_TYPE_SALE_EVERYONE, "Sale for everyone"), - (BATCH_DISCOUNT_TYPE_SALE_RESTRICTED, "Member/Owner only sale"), + (BATCH_DISCOUNT_TYPE_SALE_RESTRICTED, "Sale for Members"), + (BATCH_DISCOUNT_TYPE_SLIDING_PERCENT, "Sliding % Off for Members"), + (BATCH_DISCOUNT_TYPE_SLIDING_AMOUNT, "Sliding $ Off for Members"), + (BATCH_DISCOUNT_TYPE_TRACKING, "Tracking (does not change any prices)"), +]) + + +BATCH_EDITOR_UI_STANDARD = 1 +BATCH_EDITOR_UI_PAIRED_SALE = 2 +BATCH_EDITOR_UI_PARTIAL = 3 +BATCH_EDITOR_UI_TRACKING = 4 + +BATCH_EDITOR_UI = OrderedDict([ + (BATCH_EDITOR_UI_STANDARD, "Standard"), + (BATCH_EDITOR_UI_PAIRED_SALE, "Paired Sale"), + (BATCH_EDITOR_UI_PARTIAL, "Partial"), + (BATCH_EDITOR_UI_TRACKING, "Tracking"), ]) From 01852ceecc437ac7b5f5c429d7d1f5487c40daa4 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 15 Jan 2025 08:45:59 -0600 Subject: [PATCH 2/3] fix: misc. cleanup for sales batch models --- corepos/db/office_op/model.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index 68627c0..6087f67 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -1636,7 +1636,9 @@ class BatchType(Base): """ __tablename__ = 'batchType' - id = sa.Column('batchTypeID', sa.Integer(), primary_key=True, autoincrement=False, nullable=False) + # nb. this is *not* autoincrement for some reason; must + # calculate new ID manually based on max existing + id = sa.Column('batchTypeID', sa.Integer(), nullable=False, primary_key=True, autoincrement=False) description = sa.Column('typeDesc', sa.String(length=50), nullable=True) @@ -1661,9 +1663,6 @@ class Batch(Base): Represents a batch. """ __tablename__ = 'batches' - __table_args__ = ( - sa.ForeignKeyConstraint(['batchType'], ['batchType.batchTypeID']), - ) id = sa.Column('batchID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False) @@ -1673,7 +1672,8 @@ class Batch(Base): name = sa.Column('batchName', sa.String(length=80), nullable=True) - batch_type_id = sa.Column('batchType', sa.Integer(), nullable=True) + batch_type_id = sa.Column('batchType', sa.Integer(), + sa.ForeignKey('batchType.batchTypeID'), nullable=True) batch_type = orm.relationship(BatchType) discount_type = sa.Column('discountType', sa.Integer(), nullable=True) @@ -1695,16 +1695,18 @@ class BatchItem(Base): Represents a batch "list" item. """ __tablename__ = 'batchList' - __table_args__ = ( - sa.ForeignKeyConstraint(['batchID'], ['batches.batchID']), - ) id = sa.Column('listID', sa.Integer(), primary_key=True, autoincrement=True, nullable=False) - batch_id = sa.Column('batchID', sa.Integer(), nullable=True) + batch_id = sa.Column('batchID', sa.Integer(), + sa.ForeignKey('batches.batchID'), nullable=True) batch = orm.relationship(Batch, backref=orm.backref('items')) upc = sa.Column(sa.String(length=13), nullable=True) + product = orm.relationship( + Product, + primaryjoin=Product.upc == upc, + foreign_keys=[upc]) sale_price = sa.Column('salePrice', sa.Numeric(precision=9, scale=3), nullable=True) From b8ca60b508a2e3689ee7061be0d2c15841f07a64 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 15 Jan 2025 08:51:40 -0600 Subject: [PATCH 3/3] =?UTF-8?q?bump:=20version=200.3.3=20=E2=86=92=200.3.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccc62cb..39309fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to pyCOREPOS 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.4 (2025-01-15) + +### Fix + +- misc. cleanup for sales batch models +- add more enums for batch discount type, editor UI + ## v0.3.3 (2025-01-13) ### Fix diff --git a/pyproject.toml b/pyproject.toml index a59e830..143843f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "pyCOREPOS" -version = "0.3.3" +version = "0.3.4" description = "Python Interface to CORE POS" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]