refactor: handle diff amount in various names
This commit is contained in:
parent
5695d6a5a6
commit
f4a65cccc4
@ -980,7 +980,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
|
||||
@ -992,7 +995,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"
|
||||
@ -1024,7 +1028,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,
|
||||
}
|
||||
)
|
||||
@ -1043,7 +1047,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,
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user