Add start date support for "future" pricing batch
This commit is contained in:
parent
cb6499522e
commit
6b466bb90f
22
tailbone/templates/batch/pricing/configure.mako
Normal file
22
tailbone/templates/batch/pricing/configure.mako
Normal file
|
@ -0,0 +1,22 @@
|
|||
## -*- coding: utf-8; -*-
|
||||
<%inherit file="/configure.mako" />
|
||||
|
||||
<%def name="form_content()">
|
||||
|
||||
<h3 class="block is-size-3">Options</h3>
|
||||
<div class="block" style="padding-left: 2rem;">
|
||||
|
||||
<b-field>
|
||||
<b-checkbox name="rattail.batch.pricing.allow_future"
|
||||
v-model="simpleSettings['rattail.batch.pricing.allow_future']"
|
||||
native-value="true"
|
||||
@input="settingsNeedSaved = true">
|
||||
Allow "future" pricing
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
</div>
|
||||
</%def>
|
||||
|
||||
|
||||
${parent.body()}
|
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2021 Lance Edgar
|
||||
# Copyright © 2010-2022 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -52,6 +52,7 @@ class PricingBatchView(BatchMasterView):
|
|||
bulk_deletable = True
|
||||
rows_editable = True
|
||||
rows_bulk_deletable = True
|
||||
configurable = True
|
||||
|
||||
labels = {
|
||||
'min_diff_threshold': "Min $ Diff",
|
||||
|
@ -62,6 +63,7 @@ class PricingBatchView(BatchMasterView):
|
|||
grid_columns = [
|
||||
'id',
|
||||
'description',
|
||||
'start_date',
|
||||
'created',
|
||||
'created_by',
|
||||
'rowcount',
|
||||
|
@ -75,6 +77,7 @@ class PricingBatchView(BatchMasterView):
|
|||
'id',
|
||||
'input_filename',
|
||||
'description',
|
||||
'start_date',
|
||||
'min_diff_threshold',
|
||||
'min_diff_percent',
|
||||
'calculate_for_manual',
|
||||
|
@ -147,8 +150,24 @@ class PricingBatchView(BatchMasterView):
|
|||
'status_text',
|
||||
]
|
||||
|
||||
def allow_future_pricing(self):
|
||||
return self.batch_handler.allow_future()
|
||||
|
||||
def configure_form(self, f):
|
||||
super(PricingBatchView, self).configure_form(f)
|
||||
app = self.get_rattail_app()
|
||||
batch = f.model_instance
|
||||
|
||||
if self.creating or self.editing:
|
||||
if self.allow_future_pricing():
|
||||
f.set_type('start_date', 'date_jquery')
|
||||
f.set_helptext('start_date', "Only set this for a \"FUTURE\" batch.")
|
||||
else:
|
||||
f.remove('start_date')
|
||||
else: # viewing or deleting
|
||||
if not self.allow_future_pricing():
|
||||
if not batch.start_date:
|
||||
f.remove('start_date')
|
||||
|
||||
f.set_type('min_diff_threshold', 'currency')
|
||||
|
||||
|
@ -349,6 +368,15 @@ class PricingBatchView(BatchMasterView):
|
|||
|
||||
return xlrow
|
||||
|
||||
def configure_get_simple_settings(self):
|
||||
return [
|
||||
|
||||
# options
|
||||
{'section': 'rattail.batch',
|
||||
'option': 'pricing.allow_future',
|
||||
'type': bool},
|
||||
]
|
||||
|
||||
|
||||
def includeme(config):
|
||||
PricingBatchView.defaults(config)
|
||||
|
|
|
@ -1892,14 +1892,15 @@ class ProductView(MasterView):
|
|||
return {'product': data}
|
||||
|
||||
def get_supported_batches(self):
|
||||
app = self.get_rattail_app()
|
||||
pricing = app.get_batch_handler('pricing')
|
||||
return OrderedDict([
|
||||
('labels', {
|
||||
'spec': self.rattail_config.get('rattail.batch', 'labels.handler',
|
||||
default='rattail.batch.labels:LabelBatchHandler'),
|
||||
}),
|
||||
('pricing', {
|
||||
'spec': self.rattail_config.get('rattail.batch', 'pricing.handler',
|
||||
default='rattail.batch.pricing:PricingBatchHandler'),
|
||||
'spec': pricing.get_spec(),
|
||||
}),
|
||||
('delproduct', {
|
||||
'spec': self.rattail_config.get('rattail.batch', 'delproduct.handler',
|
||||
|
@ -2003,7 +2004,9 @@ class ProductView(MasterView):
|
|||
"""
|
||||
Return params schema for making a pricing batch.
|
||||
"""
|
||||
return colander.SchemaNode(
|
||||
app = self.get_rattail_app()
|
||||
|
||||
schema = colander.SchemaNode(
|
||||
colander.Mapping(),
|
||||
colander.SchemaNode(colander.Decimal(), name='min_diff_threshold',
|
||||
quant='1.00', missing=colander.null,
|
||||
|
@ -2014,6 +2017,17 @@ class ProductView(MasterView):
|
|||
colander.SchemaNode(colander.Boolean(), name='calculate_for_manual'),
|
||||
)
|
||||
|
||||
pricing = app.get_batch_handler('pricing')
|
||||
if pricing.allow_future():
|
||||
schema.insert(0, colander.SchemaNode(
|
||||
colander.Date(),
|
||||
name='start_date',
|
||||
missing=colander.null,
|
||||
title="Start Date (FUTURE only)",
|
||||
widget=forms.widgets.JQueryDateWidget()))
|
||||
|
||||
return schema
|
||||
|
||||
def make_batch_params_schema_delproduct(self):
|
||||
"""
|
||||
Return params schema for making a "delete products" batch.
|
||||
|
|
Loading…
Reference in a new issue