refactor: use payment's CC for gain/loss if company default is unset

(cherry picked from commit d6a3b9a5c7)

# Conflicts:
#	erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py
This commit is contained in:
ruthra kumar
2023-09-03 07:21:09 +05:30
committed by Mergify
parent 7fd96d0116
commit d24c8b1bbc
5 changed files with 40 additions and 7 deletions

View File

@@ -1724,6 +1724,7 @@ class QueryPaymentLedger(object):
ple.posting_date,
ple.due_date,
ple.account_currency.as_("currency"),
ple.cost_center.as_("cost_center"),
Sum(ple.amount).as_("amount"),
Sum(ple.amount_in_account_currency).as_("amount_in_account_currency"),
)
@@ -1786,6 +1787,7 @@ class QueryPaymentLedger(object):
).as_("paid_amount_in_account_currency"),
Table("vouchers").due_date,
Table("vouchers").currency,
Table("vouchers").cost_center.as_("cost_center"),
)
.where(Criterion.all(filter_on_outstanding_amount))
)
@@ -1869,6 +1871,7 @@ def create_gain_loss_journal(
ref2_dt,
ref2_dn,
ref2_detail_no,
cost_center,
) -> str:
journal_entry = frappe.new_doc("Journal Entry")
journal_entry.voucher_type = "Exchange Gain Or Loss"
@@ -1894,7 +1897,7 @@ def create_gain_loss_journal(
"party": party,
"account_currency": party_account_currency,
"exchange_rate": 0,
"cost_center": erpnext.get_default_cost_center(company),
"cost_center": cost_center or erpnext.get_default_cost_center(company),
"reference_type": ref1_dt,
"reference_name": ref1_dn,
"reference_detail_no": ref1_detail_no,
@@ -1910,7 +1913,7 @@ def create_gain_loss_journal(
"account": gain_loss_account,
"account_currency": gain_loss_account_currency,
"exchange_rate": 1,
"cost_center": erpnext.get_default_cost_center(company),
"cost_center": cost_center or erpnext.get_default_cost_center(company),
"reference_type": ref2_dt,
"reference_name": ref2_dn,
"reference_detail_no": ref2_detail_no,