I have some extra calculation for grand total in the sales order. But I can’t adjust my calculated results with original grand_total
value.
class BkSalesOrder(SalesOrder):
def validate(self):
self.grand_total = 169.9
self._add_payments_record()
super(SalesOrder, self).validate()
def _add_payments_record(self):
list_of_payments_schecule: list = []
self.agreement_period = int(self.agreement_period)
rental_price = ItemRentalPrice(float(self.rounded_total), int(self.agreement_period))
monthly_rental_amount: float = rental_price.calculate()
#list_of_payments_schecule.append(PaymentSchedule('Transportation Fee', 10.00, self.name + '-' + 'Payment 1'))
list_of_payments_schecule.append(PaymentSchedule('Payment 1', monthly_rental_amount, self.name + '-' + 'Payment 2'))
for i in range(1, self.agreement_period):
list_of_payments_schecule.append(PaymentSchedule('Payment {0}'.format(i), monthly_rental_amount, self.name + '-' + 'Payment {0}'.format(i + 1)))
print(sum([obj.monthly_rental_amount for obj in list_of_payments_schecule]))
for index, schedule in enumerate(list_of_payments_schecule):
payment_schedule = self.append('payment_schedule', {})
payment_schedule.number_of_payment = schedule.no_of_payment
payment_schedule.payment_amount = schedule.monthly_rental_amount
payment_schedule.payment_id = schedule.payment_id
payment_schedule.due_date = self._get_next_due_date(datetime.now().date(), index)
def _get_next_due_date(self, date, i):
add_month_to_date = add_months(date, i)
if isinstance(add_month_to_date, datetime):
return add_month_to_date.date()
else:
return add_month_to_date
ERPnext13