Add setting to determine if supplier price breaks are used in overall price calculations (#3943)

This commit is contained in:
Oliver 2022-11-17 09:27:07 +11:00 committed by GitHub
parent d7c4dd1f01
commit 1e1662ef0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 12 deletions

View File

@ -1093,6 +1093,13 @@ class InvenTreeSetting(BaseInvenTreeSetting):
] ]
}, },
'PRICING_USE_SUPPLIER_PRICING': {
'name': _('Use Supplier Pricing'),
'description': _('Include supplier price breaks in overall pricing calculations'),
'default': True,
'validator': bool,
},
'PRICING_UPDATE_DAYS': { 'PRICING_UPDATE_DAYS': {
'name': _('Pricing Rebuild Time'), 'name': _('Pricing Rebuild Time'),
'description': _('Number of days before part pricing is automatically updated'), 'description': _('Number of days before part pricing is automatically updated'),

View File

@ -2575,14 +2575,26 @@ class PartPricing(models.Model):
overall_min = None overall_min = None
overall_max = None overall_max = None
# Calculate overall minimum cost min_costs = [
for cost in [
self.bom_cost_min, self.bom_cost_min,
self.purchase_cost_min, self.purchase_cost_min,
self.internal_cost_min, self.internal_cost_min,
self.supplier_price_min, self.variant_cost_min
self.variant_cost_min, ]
]:
max_costs = [
self.bom_cost_max,
self.purchase_cost_max,
self.internal_cost_max,
self.variant_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)
# Calculate overall minimum cost
for cost in min_costs:
if cost is None: if cost is None:
continue continue
@ -2593,13 +2605,7 @@ class PartPricing(models.Model):
overall_min = cost overall_min = cost
# Calculate overall maximum cost # Calculate overall maximum cost
for cost in [ for cost in max_costs:
self.bom_cost_max,
self.purchase_cost_max,
self.internal_cost_max,
self.supplier_price_max,
self.variant_cost_max,
]:
if cost is None: if cost is None:
continue continue

View File

@ -15,6 +15,7 @@
{% include "InvenTree/settings/setting.html" with key="PART_BOM_USE_INTERNAL_PRICE" %} {% include "InvenTree/settings/setting.html" with key="PART_BOM_USE_INTERNAL_PRICE" %}
{% include "InvenTree/settings/setting.html" with key="PRICING_DECIMAL_PLACES" %} {% 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_UPDATE_DAYS" icon='fa-calendar-alt' %}
{% include "InvenTree/settings/setting.html" with key="PRICING_USE_SUPPLIER_PRICING" icon='fa-check-circle' %}
</tbody> </tbody>
</table> </table>
</div> </div>