This commit is contained in:
2026-02-15 14:23:33 +01:00
parent 4059cd591e
commit 479e0d4d5a
4 changed files with 35 additions and 33 deletions

View File

@@ -155,12 +155,10 @@ class PaymentTermLine(sequence_ordered(), ModelSQL, ModelView):
self.ratio = self.round(1 / self.divisor, self.ratio = self.round(1 / self.divisor,
self.__class__.ratio.digits[1]) self.__class__.ratio.digits[1])
def get_date(self, date, purchase_line = None): def get_date(self, date, line = None):
#find date based on trigger: #find date based on trigger:
if purchase_line and self.trigger_event: if line and self.trigger_event:
PurchaseLine = Pool().get('purchase.line') trigger_date = line.get_date(self.trigger_event)
purchase_line = PurchaseLine(purchase_line)
trigger_date = purchase_line.get_date(self.trigger_event)
if trigger_date: if trigger_date:
date = trigger_date date = trigger_date

View File

@@ -57,7 +57,7 @@ class Fee(ModelSQL,ModelView):
('lumpsum', 'Lump sum'), ('lumpsum', 'Lump sum'),
('perqt', 'Per qt'), ('perqt', 'Per qt'),
('pprice', '% price'), ('pprice', '% price'),
('rate', '% Mth'), ('rate', '% rate'),
('pcost', '% cost price'), ('pcost', '% cost price'),
('ppack', 'Per packing'), ('ppack', 'Per packing'),
], 'Mode', required=True) ], 'Mode', required=True)
@@ -318,32 +318,34 @@ class Fee(ModelSQL,ModelView):
#take period with estimated trigger date #take period with estimated trigger date
if self.line: if self.line:
if self.line.purchase.payment_term: if self.line.purchase.payment_term:
est_date = self.line.purchase.payment_term.get_date()
beg_date = self.fee_date if self.fee_date else Date.today() beg_date = self.fee_date if self.fee_date else Date.today()
factor = InterestCalculator.calculate( est_date = self.line.purchase.payment_term[0].get_date(beg_date)
start_date=beg_date, if est_date and beg_date:
end_date=est_date, factor = InterestCalculator.calculate(
rate=self.price, start_date=beg_date,
rate_type='annual', end_date=est_date,
convention='ACT/360', rate=self.price,
compounding='simple' rate_type='annual',
) convention='ACT/360',
compounding='simple'
)
return round(factor * self.line.unit_price * (self.quantity if self.quantity else 0) * sign,2) return round(factor * self.line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
if self.sale_line: if self.sale_line:
if self.sale_line.sale.payment_term: if self.sale_line.sale.payment_term:
est_date = self.sale_line.sale.payment_term.get_date()
beg_date = self.fee_date if self.fee_date else Date.today() beg_date = self.fee_date if self.fee_date else Date.today()
factor = InterestCalculator.calculate( est_date = self.sale_line.sale.payment_term.get_date(beg_date)
start_date=beg_date, if est_date and beg_date:
end_date=est_date, factor = InterestCalculator.calculate(
rate=self.price, start_date=beg_date,
rate_type='annual', end_date=est_date,
convention='ACT/360', rate=self.price,
compounding='simple' rate_type='annual',
) convention='ACT/360',
compounding='simple'
)
return round(factor * self.sale_line.unit_price * (self.quantity if self.quantity else 0) * sign,2) return round(factor * self.sale_line.unit_price * (self.quantity if self.quantity else 0) * sign,2)
elif self.mode == 'perqt': elif self.mode == 'perqt':
if self.shipment_in: if self.shipment_in:

View File

@@ -460,10 +460,12 @@ class SaleLine(metaclass=PoolMeta):
LotQt = Pool().get('lot.qt') LotQt = Pool().get('lot.qt')
return LotQt.search([('lot_s','=',self.lots[0].id),('lot_p','>',0)]) return LotQt.search([('lot_s','=',self.lots[0].id),('lot_p','>',0)])
# @fields.depends('quantity') def get_date(self,trigger_event):
# def on_change_with_quantity_theorical(self): date = None
# if not self.quantity_theorical: if self.estimated_date:
# return self.quantity trigger_date = [d.estimated_date for d in self.estimated_date if d.trigger == trigger_event]
trigger_date = trigger_date[0] if trigger_date else None
return date
def get_tol_min(self,name): def get_tol_min(self,name):
if self.inherit_tol: if self.inherit_tol:

View File

@@ -76,10 +76,10 @@ this repository contains the full copyright notices and license terms. -->
<page string="Summary" col="4" id="summary"> <page string="Summary" col="4" id="summary">
<field name="price_summary" /> <field name="price_summary" />
</page> </page>
<page string="Estimated dates" col="4" id="estimated">
<field name="estimated_date" />
</page>
</notebook> </notebook>
</page> </page>
<page string="Estimated dates" col="4" id="estimated">
<field name="estimated_date" />
</page>
</xpath> </xpath>
</data> </data>