chore: remove debugging statements and fixing failing unit tests

This commit is contained in:
ruthra kumar 2023-06-26 21:43:20 +05:30
parent 7b516f8463
commit ee3ce82ea8

View File

@ -977,26 +977,25 @@ class AccountsController(TransactionBase):
if self.get("doctype") == "Journal Entry": if self.get("doctype") == "Journal Entry":
if args: if args:
for arg in args: for arg in args:
print(arg) if arg.get("difference_amount", 0) != 0 and arg.get("difference_account"):
if arg.get("difference_amount") != 0 and arg.get("difference_account"):
journal_entry = frappe.new_doc("Journal Entry") journal_entry = frappe.new_doc("Journal Entry")
journal_entry.voucher_type = "Exchange Gain Or Loss" journal_entry.voucher_type = "Exchange Gain Or Loss"
journal_entry.company = self.company journal_entry.company = self.company
journal_entry.posting_date = nowdate() journal_entry.posting_date = nowdate()
journal_entry.multi_currency = 1 journal_entry.multi_currency = 1
party_account = arg.account party_account = arg.get("account")
party_account_currency = frappe.get_cached_value( party_account_currency = frappe.get_cached_value(
"Account", party_account, "account_currency" "Account", party_account, "account_currency"
) )
dr_or_cr = "debit" if arg.difference_amount > 0 else "credit" dr_or_cr = "debit" if arg.get("difference_amount") > 0 else "credit"
if arg.reference_doctype == "Purchase Invoice": if arg.reference_doctype == "Purchase Invoice":
dr_or_cr = "debit" if dr_or_cr == "credit" else "credit" dr_or_cr = "debit" if dr_or_cr == "credit" else "credit"
reverse_dr_or_cr = "debit" if dr_or_cr == "credit" else "credit" reverse_dr_or_cr = "debit" if dr_or_cr == "credit" else "credit"
gain_loss_account = arg.difference_account gain_loss_account = arg.get("difference_account")
if not gain_loss_account: if not gain_loss_account:
frappe.throw( frappe.throw(
@ -1014,14 +1013,14 @@ class AccountsController(TransactionBase):
journal_account = frappe._dict( journal_account = frappe._dict(
{ {
"account": party_account, "account": party_account,
"party_type": arg.party_type, "party_type": arg.get("party_type"),
"party": arg.party, "party": arg.get("party"),
"account_currency": party_account_currency, "account_currency": party_account_currency,
"exchange_rate": 0, "exchange_rate": 0,
"cost_center": erpnext.get_default_cost_center(self.company), "cost_center": erpnext.get_default_cost_center(self.company),
"reference_type": arg.against_voucher_type, "reference_type": arg.get("against_voucher_type"),
"reference_name": arg.against_voucher, "reference_name": arg.get("against_voucher"),
"reference_detail_no": arg.idx, "reference_detail_no": arg.get("idx"),
dr_or_cr: abs(arg.difference_amount), dr_or_cr: abs(arg.difference_amount),
dr_or_cr + "_in_account_currency": 0, dr_or_cr + "_in_account_currency": 0,
} }
@ -1039,8 +1038,8 @@ class AccountsController(TransactionBase):
# "reference_type": self.doctype, # "reference_type": self.doctype,
# "reference_name": self.name, # "reference_name": self.name,
# "reference_detail_no": arg.idx, # "reference_detail_no": arg.idx,
reverse_dr_or_cr + "_in_account_currency": abs(arg.difference_amount), reverse_dr_or_cr + "_in_account_currency": abs(arg.get("difference_amount")),
reverse_dr_or_cr: abs(arg.difference_amount), reverse_dr_or_cr: abs(arg.get("difference_amount")),
} }
) )