mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-15 04:45:09 +00:00
fix: set correct paid/receive amount if doc currency is different from party account currency
(cherry picked from commit 9612521894)
This commit is contained in:
@@ -3300,26 +3300,25 @@ def set_paid_amount_and_received_amount(
|
|||||||
if party_account_currency == bank.account_currency:
|
if party_account_currency == bank.account_currency:
|
||||||
paid_amount = received_amount = abs(outstanding_amount)
|
paid_amount = received_amount = abs(outstanding_amount)
|
||||||
else:
|
else:
|
||||||
company_currency = frappe.get_cached_value("Company", doc.get("company"), "default_currency")
|
# settings if it is for receive
|
||||||
if payment_type == "Receive":
|
paid_amount = abs(outstanding_amount)
|
||||||
paid_amount = abs(outstanding_amount)
|
if bank_amount:
|
||||||
if bank_amount:
|
received_amount = bank_amount
|
||||||
received_amount = bank_amount
|
|
||||||
else:
|
|
||||||
if bank and company_currency != bank.account_currency:
|
|
||||||
received_amount = paid_amount / doc.get("conversion_rate", 1)
|
|
||||||
else:
|
|
||||||
received_amount = paid_amount * doc.get("conversion_rate", 1)
|
|
||||||
else:
|
else:
|
||||||
received_amount = abs(outstanding_amount)
|
company_currency = frappe.get_cached_value("Company", doc.get("company"), "default_currency")
|
||||||
if bank_amount:
|
if bank and company_currency != bank.account_currency:
|
||||||
paid_amount = bank_amount
|
# doc currency can be different from bank currency
|
||||||
|
posting_date = doc.get("posting_date") or doc.get("transaction_date")
|
||||||
|
conversion_rate = get_exchange_rate(
|
||||||
|
bank.account_currency, party_account_currency, posting_date
|
||||||
|
)
|
||||||
|
received_amount = paid_amount / conversion_rate
|
||||||
else:
|
else:
|
||||||
if bank and company_currency != bank.account_currency:
|
received_amount = paid_amount * doc.get("conversion_rate", 1)
|
||||||
paid_amount = received_amount / doc.get("conversion_rate", 1)
|
|
||||||
else:
|
# if payment type is pay, then paid amount and received amount are swapped
|
||||||
# if party account currency and bank currency is different then populate paid amount as well
|
if payment_type == "Pay":
|
||||||
paid_amount = received_amount * doc.get("conversion_rate", 1)
|
paid_amount, received_amount = received_amount, paid_amount
|
||||||
|
|
||||||
return paid_amount, received_amount
|
return paid_amount, received_amount
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user