From 4c5a83d6cf7e4b39a403b1e99a2b1c443f854ac9 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Mon, 25 Sep 2023 19:55:40 +0530 Subject: [PATCH] fix: set against type in controllers --- erpnext/accounts/doctype/journal_entry/journal_entry.py | 1 + erpnext/accounts/doctype/payment_entry/payment_entry.py | 7 +++++++ erpnext/controllers/accounts_controller.py | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 85ef6f76d2..0616643a68 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -906,6 +906,7 @@ class JournalEntry(AccountsController): "party_type": d.party_type, "due_date": self.due_date, "party": d.party, + "against_type": "Account", "against": d.against_account, "debit": flt(d.debit, d.precision("debit")), "credit": flt(d.credit, d.precision("credit")), diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 38a520996c..6cfc072aea 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1074,6 +1074,7 @@ class PaymentEntry(AccountsController): "account": self.party_account, "party_type": self.party_type, "party": self.party, + "against_type": "Account", "against": against_account, "account_currency": self.party_account_currency, "cost_center": self.cost_center, @@ -1232,6 +1233,7 @@ class PaymentEntry(AccountsController): { "account": self.paid_from, "account_currency": self.paid_from_account_currency, + "against_type": self.party_type if self.payment_type == "Pay" else "Account", "against": self.party if self.payment_type == "Pay" else self.paid_to, "credit_in_account_currency": self.paid_amount, "credit": self.base_paid_amount, @@ -1247,6 +1249,7 @@ class PaymentEntry(AccountsController): { "account": self.paid_to, "account_currency": self.paid_to_account_currency, + "against_type": self.party_type if self.payment_type == "Receive" else "Account", "against": self.party if self.payment_type == "Receive" else self.paid_from, "debit_in_account_currency": self.received_amount, "debit": self.base_received_amount, @@ -1271,6 +1274,7 @@ class PaymentEntry(AccountsController): rev_dr_or_cr = "credit" if dr_or_cr == "debit" else "debit" against = self.party or self.paid_to + against_type = self.party_type or "Account" payment_account = self.get_party_account_for_taxes() tax_amount = d.tax_amount base_tax_amount = d.base_tax_amount @@ -1279,6 +1283,7 @@ class PaymentEntry(AccountsController): self.get_gl_dict( { "account": d.account_head, + "against_type": against_type, "against": against, dr_or_cr: tax_amount, dr_or_cr + "_in_account_currency": base_tax_amount @@ -1304,6 +1309,7 @@ class PaymentEntry(AccountsController): self.get_gl_dict( { "account": payment_account, + "against_type": against_type, "against": against, rev_dr_or_cr: tax_amount, rev_dr_or_cr + "_in_account_currency": base_tax_amount @@ -1329,6 +1335,7 @@ class PaymentEntry(AccountsController): { "account": d.account, "account_currency": account_currency, + "against_type": self.party_type or "Account", "against": self.party or self.paid_from, "debit_in_account_currency": d.amount, "debit": d.amount, diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index e635aa7924..d77b8a3c7f 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1040,6 +1040,7 @@ class AccountsController(TransactionBase): ) credit_or_debit = "credit" if self.doctype == "Purchase Invoice" else "debit" + against_type = "Supplier" if self.doctype == "Purchase Invoice" else "Customer" against = self.supplier if self.doctype == "Purchase Invoice" else self.customer if precision_loss: @@ -1047,6 +1048,7 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": round_off_account, + "against_type": against_type, "against": against, credit_or_debit: precision_loss, "cost_center": round_off_cost_center @@ -1394,11 +1396,13 @@ class AccountsController(TransactionBase): if self.doctype == "Purchase Invoice": dr_or_cr = "credit" rev_dr_cr = "debit" + against_type = "Supplier" supplier_or_customer = self.supplier else: dr_or_cr = "debit" rev_dr_cr = "credit" + against_type = "Customer" supplier_or_customer = self.customer if enable_discount_accounting: @@ -1423,6 +1427,7 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": item.discount_account, + "against_type": against_type, "against": supplier_or_customer, dr_or_cr: flt( discount_amount * self.get("conversion_rate"), item.precision("discount_amount") @@ -1441,6 +1446,7 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": income_or_expense_account, + "against_type": against_type, "against": supplier_or_customer, rev_dr_cr: flt( discount_amount * self.get("conversion_rate"), item.precision("discount_amount") @@ -1464,6 +1470,7 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": self.additional_discount_account, + "against_type": against_type, "against": supplier_or_customer, dr_or_cr: self.base_discount_amount, "cost_center": self.cost_center,