fix: exchange gain loss not set for advances linked with invoices (#26436)

This commit is contained in:
Saqib
2021-07-12 18:33:16 +05:30
committed by GitHub
parent ca6e4bed9f
commit 7fb64d1645
9 changed files with 441 additions and 455 deletions

View File

@@ -472,7 +472,8 @@ def update_reference_in_payment_entry(d, payment_entry, do_not_save=False):
"total_amount": d.grand_total,
"outstanding_amount": d.outstanding_amount,
"allocated_amount": d.allocated_amount,
"exchange_rate": d.exchange_rate
"exchange_rate": d.exchange_rate if not d.exchange_gain_loss else payment_entry.get_exchange_rate(),
"exchange_gain_loss": d.exchange_gain_loss # only populated from invoice in case of advance allocation
}
if d.voucher_detail_no:
@@ -498,12 +499,15 @@ def update_reference_in_payment_entry(d, payment_entry, do_not_save=False):
payment_entry.set_amounts()
if d.difference_amount and d.difference_account:
payment_entry.set_gain_or_loss(account_details={
account_details = {
'account': d.difference_account,
'cost_center': payment_entry.cost_center or frappe.get_cached_value('Company',
payment_entry.company, "cost_center"),
'amount': d.difference_amount
})
payment_entry.company, "cost_center")
}
if d.difference_amount:
account_details['amount'] = d.difference_amount
payment_entry.set_gain_or_loss(account_details=account_details)
if not do_not_save:
payment_entry.save(ignore_permissions=True)