Supplier pricing override (#3988)

* Adds new option for overriding supplier price break pricing data

* Add logic for overriding supplier part pricing with historical information

* Prevent caching
This commit is contained in:
Oliver 2022-11-22 16:28:55 +11:00 committed by GitHub
parent 4f5adef402
commit 8cd782dc8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View File

@ -1105,6 +1105,13 @@ class InvenTreeSetting(BaseInvenTreeSetting):
'validator': bool,
},
'PRICING_PURCHASE_HISTORY_OVERRIDES_SUPPLIER': {
'name': _('Purchase History Override'),
'description': _('Historical purchase order pricing overrides supplier price breaks'),
'default': False,
'validator': bool,
},
'PRICING_USE_VARIANT_PRICING': {
'name': _('Use Variant Pricing'),
'description': _('Include variant pricing in overall pricing calculations'),

View File

@ -2620,11 +2620,17 @@ class PartPricing(models.Model):
self.internal_cost_max,
]
if InvenTreeSetting.get_setting('PRICING_USE_SUPPLIER_PRICING', True):
min_costs.append(self.supplier_price_min)
max_costs.append(self.supplier_price_max)
purchase_history_override = InvenTreeSetting.get_setting('PRICING_PURCHASE_HISTORY_OVERRIDES_SUPPLIER', False, cache=False)
if InvenTreeSetting.get_setting('PRICING_USE_VARIANT_PRICING', True):
if InvenTreeSetting.get_setting('PRICING_USE_SUPPLIER_PRICING', True, cache=False):
# Add supplier pricing data, *unless* historical pricing information should override
if self.purchase_cost_min is None or not purchase_history_override:
min_costs.append(self.supplier_price_min)
if self.purchase_cost_max is None or not purchase_history_override:
max_costs.append(self.supplier_price_max)
if InvenTreeSetting.get_setting('PRICING_USE_VARIANT_PRICING', True, cache=False):
min_costs.append(self.variant_cost_min)
max_costs.append(self.variant_cost_max)

View File

@ -16,6 +16,7 @@
{% include "InvenTree/settings/setting.html" with key="PRICING_DECIMAL_PLACES" %}
{% include "InvenTree/settings/setting.html" with key="PRICING_UPDATE_DAYS" icon='fa-calendar-alt' %}
{% include "InvenTree/settings/setting.html" with key="PRICING_USE_SUPPLIER_PRICING" icon='fa-check-circle' %}
{% include "InvenTree/settings/setting.html" with key="PRICING_PURCHASE_HISTORY_OVERRIDES_SUPPLIER" icon='fa-shopping-cart' %}
{% include "InvenTree/settings/setting.html" with key="PRICING_USE_VARIANT_PRICING" icon='fa-check-circle' %}
{% include "InvenTree/settings/setting.html" with key="PRICING_ACTIVE_VARIANTS" %}