fix: setting of gain/loss if party account is in company currency
(cherry picked from commit 64efe8bf15)
This commit is contained in:
committed by
mergify-bot
parent
986ca8815d
commit
af531372da
@@ -690,13 +690,17 @@ class AccountsController(TransactionBase):
|
|||||||
.format(d.reference_name, d.against_order))
|
.format(d.reference_name, d.against_order))
|
||||||
|
|
||||||
def set_advance_gain_or_loss(self):
|
def set_advance_gain_or_loss(self):
|
||||||
if not self.get("advances"):
|
if self.get('conversion_rate') == 1 or not self.get("advances"):
|
||||||
|
return
|
||||||
|
|
||||||
|
is_purchase_invoice = self.doctype == 'Purchase Invoice'
|
||||||
|
party_account = self.credit_to if is_purchase_invoice else self.debit_to
|
||||||
|
if get_account_currency(party_account) != self.currency:
|
||||||
return
|
return
|
||||||
|
|
||||||
for d in self.get("advances"):
|
for d in self.get("advances"):
|
||||||
advance_exchange_rate = d.ref_exchange_rate
|
advance_exchange_rate = d.ref_exchange_rate
|
||||||
if (d.allocated_amount and self.conversion_rate != 1
|
if (d.allocated_amount and self.conversion_rate != advance_exchange_rate):
|
||||||
and self.conversion_rate != advance_exchange_rate):
|
|
||||||
|
|
||||||
base_allocated_amount_in_ref_rate = advance_exchange_rate * d.allocated_amount
|
base_allocated_amount_in_ref_rate = advance_exchange_rate * d.allocated_amount
|
||||||
base_allocated_amount_in_inv_rate = self.conversion_rate * d.allocated_amount
|
base_allocated_amount_in_inv_rate = self.conversion_rate * d.allocated_amount
|
||||||
|
|||||||
Reference in New Issue
Block a user