Changeset - 72d1b070bd39
[Not reviewed]
0 3 1
Lance Edgar (lance) - 2 years ago 2022-06-14 13:48:22
lance@edbob.org
Add basic start date support for "future" pricing batch
4 files changed with 53 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rattail/batch/handlers.py
Show inline comments
 
@@ -96,6 +96,10 @@ class BatchHandler(object):
 
        """
 
        return self.batch_model_class.batch_key
 

	
 
    @classmethod
 
    def get_spec(cls):
 
        return '{}:{}'.format(cls.__module__, cls.__name__)
 

	
 
    def get_model_title(self):
 
        return self.batch_model_class.get_model_title()
 

	
rattail/batch/pricing.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2020 Lance Edgar
 
#  Copyright © 2010-2022 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -46,6 +46,16 @@ class PricingBatchHandler(BatchHandler):
 
    # cached decimal object used for rounding percentages, below
 
    percent_decimal = decimal.Decimal('.001')
 

	
 
    def allow_future(self):
 
        """
 
        Returns boolean indicating whether "future" price changes
 
        should be allowed.
 

	
 
        :returns: ``True`` if future price changes allowed; else ``False``.
 
        """
 
        return self.config.getbool('rattail.batch', 'pricing.allow_future',
 
                                   default=False)
 

	
 
    def should_populate(self, batch):
 
        if batch.params and batch.params.get('auto_generate_from_srp_breach'):
 
            return True
rattail/db/alembic/versions/9c111f4b5451_add_start_end_for_pricing_batch.py
Show inline comments
 
new file 100644
 
# -*- coding: utf-8; -*-
 
"""add start/end for pricing batch
 

	
 
Revision ID: 9c111f4b5451
 
Revises: 11fe87e4cd5f
 
Create Date: 2022-06-14 12:41:59.320748
 

	
 
"""
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
# revision identifiers, used by Alembic.
 
revision = '9c111f4b5451'
 
down_revision = '11fe87e4cd5f'
 
branch_labels = None
 
depends_on = None
 

	
 
from alembic import op
 
import sqlalchemy as sa
 
import rattail.db.types
 

	
 

	
 

	
 
def upgrade():
 

	
 
    # batch_pricing
 
    op.add_column('batch_pricing', sa.Column('start_date', sa.Date(), nullable=True))
 

	
 

	
 
def downgrade():
 

	
 
    # batch_pricing
 
    op.drop_column('batch_pricing', 'start_date')
rattail/db/model/batch/pricing.py
Show inline comments
 
@@ -2,7 +2,7 @@
 
################################################################################
 
#
 
#  Rattail -- Retail Software Framework
 
#  Copyright © 2010-2020 Lance Edgar
 
#  Copyright © 2010-2022 Lance Edgar
 
#
 
#  This file is part of Rattail.
 
#
 
@@ -58,6 +58,10 @@ class PricingBatch(BatchMixin, Base):
 
    manually priced under normal circumstances.
 
    """)
 

	
 
    start_date = sa.Column(sa.Date(), nullable=True, doc="""
 
    Start date for prices within the batch.
 
    """)
 

	
 
    input_filename = filename_column(nullable=True, doc="""
 
    Base name of the input data file, if applicable.
 
    """)
0 comments (0 inline, 0 general)