refactor: handle diff amount in various names

(cherry picked from commit f4a65cccc4)
This commit is contained in:
ruthra kumar
2023-07-14 16:51:42 +05:30
committed by Mergify
parent 077d98e0fa
commit 513721c338

View File

@@ -974,7 +974,10 @@ class AccountsController(TransactionBase):
# These are generated by Sales/Purchase Invoice during reconciliation and advance allocation.
if args:
for arg in args:
if arg.get("difference_amount", 0) != 0 and arg.get("difference_account"):
# Advance section uses `exchange_gain_loss` and reconciliation uses `difference_amount`
if (
arg.get("difference_amount", 0) != 0 or arg.get("exchange_gain_loss", 0) != 0
) and arg.get("difference_account"):
journal_entry = frappe.new_doc("Journal Entry")
journal_entry.voucher_type = "Exchange Gain Or Loss"
journal_entry.company = self.company
@@ -986,7 +989,8 @@ class AccountsController(TransactionBase):
"Account", party_account, "account_currency"
)
if arg.get("difference_amount") > 0:
difference_amount = arg.get("difference_amount") or arg.get("exchange_gain_loss")
if difference_amount > 0:
dr_or_cr = "debit" if arg.get("party_type") == "Customer" else "credit"
else:
dr_or_cr = "credit" if arg.get("party_type") == "Customer" else "debit"
@@ -1018,7 +1022,7 @@ class AccountsController(TransactionBase):
"reference_type": arg.get("against_voucher_type"),
"reference_name": arg.get("against_voucher"),
"reference_detail_no": arg.get("idx"),
dr_or_cr: abs(arg.difference_amount),
dr_or_cr: abs(difference_amount),
dr_or_cr + "_in_account_currency": 0,
}
)
@@ -1037,7 +1041,7 @@ class AccountsController(TransactionBase):
"reference_type": self.doctype,
"reference_name": self.name,
"reference_detail_no": arg.idx,
reverse_dr_or_cr: abs(arg.get("difference_amount")),
reverse_dr_or_cr: abs(difference_amount),
reverse_dr_or_cr + "_in_account_currency": 0,
}
)