From 175c7a5e305faeba4a2f983e0dbb8c6aee3e540c Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Mon, 23 Mar 2026 10:49:36 +0100 Subject: [PATCH] 23.03.26 --- modules/purchase_trade/purchase.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/purchase_trade/purchase.py b/modules/purchase_trade/purchase.py index 19a3d89..508c48f 100755 --- a/modules/purchase_trade/purchase.py +++ b/modules/purchase_trade/purchase.py @@ -1355,24 +1355,25 @@ class Line(metaclass=PoolMeta): if self.terms and self.update_pricing: Concentrate = Pool().get('concentrate.term') for t in self.terms: - if t.component: - grade = self.get_element_grade(self.assay_state,t.element) - logger.info("GRADE:%s",grade) - if grade: + grade = self.get_element_grade(self.assay_state,t.element) + logger.info("GRADE:%s",grade) + if grade: + payable_price = Decimal(0) + penalty_price = Decimal(0) + if t.penalty_rules: + penalty_price = t.penalty_rules.compute_penalty(grade) + if t.component: cp = [c for c in self.price_summary if c.price_component == t.component] if cp: cp = cp[0] price = Decimal(cp.get_last_price()) logger.info("PRICE:%s",price) - payable_price = Decimal(0) - penalty_price = Decimal(0) if t.payable_rule: payable_price = t.payable_rule.compute_payable_quantity(grade) * price / Decimal(100) - if t.penalty_rules: - penalty_price = t.penalty_rules.compute_penalty(grade) - t.manual_price = round(payable_price - penalty_price,2) - t.currency = t.component.currency - t.unit = self.unit + + t.manual_price = round(payable_price - penalty_price,2) + t.currency = self.purchase.currency + t.unit = self.unit Concentrate.save([t]) if self.price_components: