From fbeaf2b3987a6f6593a3a61d054bb1db3032c152 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sun, 14 Jan 2024 11:04:00 +0530 Subject: [PATCH] Revert "fix: set against type in controllers" This reverts commit 4c5a83d6cf7e4b39a403b1e99a2b1c443f854ac9. --- .../doctype/journal_entry/journal_entry.py | 94 ++++++------------- .../doctype/payment_entry/payment_entry.py | 7 -- erpnext/controllers/accounts_controller.py | 7 -- 3 files changed, 27 insertions(+), 81 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 79f1ab063d..e8c0e3cb5c 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -1038,75 +1038,35 @@ class JournalEntry(AccountsController): r = [x for x in r if x] remarks = "\n".join(r) - gl_dict = self.get_gl_dict( - { - "account": d.account, - "party_type": d.party_type, - "due_date": self.due_date, - "party": d.party, - "debit": flt(d.debit, d.precision("debit")), - "credit": flt(d.credit, d.precision("credit")), - "account_currency": d.account_currency, - "debit_in_account_currency": flt( - d.debit_in_account_currency, d.precision("debit_in_account_currency") - ), - "credit_in_account_currency": flt( - d.credit_in_account_currency, d.precision("credit_in_account_currency") - ), - "against_voucher_type": d.reference_type, - "against_voucher": d.reference_name, - "remarks": remarks, - "voucher_detail_no": d.reference_detail_no, - "cost_center": d.cost_center, - "project": d.project, - "finance_book": self.finance_book, - }, - item=d, + gl_map.append( + self.get_gl_dict( + { + "account": d.account, + "party_type": d.party_type, + "due_date": self.due_date, + "party": d.party, + "against": d.against_account, + "debit": flt(d.debit, d.precision("debit")), + "credit": flt(d.credit, d.precision("credit")), + "account_currency": d.account_currency, + "debit_in_account_currency": flt( + d.debit_in_account_currency, d.precision("debit_in_account_currency") + ), + "credit_in_account_currency": flt( + d.credit_in_account_currency, d.precision("credit_in_account_currency") + ), + "against_voucher_type": d.reference_type, + "against_voucher": d.reference_name, + "remarks": remarks, + "voucher_detail_no": d.reference_detail_no, + "cost_center": d.cost_center, + "project": d.project, + "finance_book": self.finance_book, + }, + item=d, + ) ) - if not self.separate_against_account_entries: - gl_dict.update( - { - "against_type": d.against_type, - "against_link": d.against_account_link, - } - ) - gl_map.append(gl_dict) - - elif d in self.against_accounts: - gl_dict.update( - { - "against_type": self.split_account.get("party_type") or "Account", - "against": self.split_account.get("party") or self.split_account.get("account"), - "against_link": self.split_account.get("party") or self.split_account.get("account"), - } - ) - gl_map.append(gl_dict) - - else: - for against_account in self.against_accounts: - against_account = against_account.as_dict() - debit = against_account.credit or against_account.credit_in_account_currency - credit = against_account.debit or against_account.debit_in_account_currency - gl_dict = gl_dict.copy() - gl_dict.update( - { - "against_type": against_account.party_type or "Account", - "against": against_account.party or against_account.account, - "against_link": against_account.party or against_account.account, - "debit": flt(debit, d.precision("debit")), - "credit": flt(credit, d.precision("credit")), - "account_currency": d.account_currency, - "debit_in_account_currency": flt( - debit / d.exchange_rate, d.precision("debit_in_account_currency") - ), - "credit_in_account_currency": flt( - credit / d.exchange_rate, d.precision("credit_in_account_currency") - ), - } - ) - gl_map.append(gl_dict) - return gl_map def make_gl_entries(self, cancel=0, adv_adj=0): diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 37bd8e6fcd..cc75d8c1f0 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1144,7 +1144,6 @@ class PaymentEntry(AccountsController): "account": self.party_account, "party_type": self.party_type, "party": self.party, - "against_type": "Account", "against": against_account, "against_link": against_account, "account_currency": self.party_account_currency, @@ -1311,7 +1310,6 @@ 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, "against_link": self.party if self.payment_type == "Pay" else self.paid_to, "credit_in_account_currency": self.paid_amount, @@ -1328,7 +1326,6 @@ 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, "against_link": self.party if self.payment_type == "Receive" else self.paid_from, "debit_in_account_currency": self.received_amount, @@ -1354,7 +1351,6 @@ 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 @@ -1363,7 +1359,6 @@ class PaymentEntry(AccountsController): self.get_gl_dict( { "account": d.account_head, - "against_type": against_type, "against": against, "against_link": against, dr_or_cr: tax_amount, @@ -1390,7 +1385,6 @@ class PaymentEntry(AccountsController): self.get_gl_dict( { "account": payment_account, - "against_type": against_type, "against": against, "against_link": against, rev_dr_or_cr: tax_amount, @@ -1417,7 +1411,6 @@ class PaymentEntry(AccountsController): { "account": d.account, "account_currency": account_currency, - "against_type": self.party_type or "Account", "against": self.party or self.paid_from, "against_link": self.party or self.paid_from, "debit_in_account_currency": d.amount, diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index aef3d31b10..be92a69a40 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -1161,7 +1161,6 @@ 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: @@ -1169,7 +1168,6 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": round_off_account, - "against_type": against_type, "against": against, "against_link": against, credit_or_debit: precision_loss, @@ -1525,13 +1523,11 @@ 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: @@ -1556,7 +1552,6 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": item.discount_account, - "against_type": against_type, "against": supplier_or_customer, "against_link": supplier_or_customer, dr_or_cr: flt( @@ -1576,7 +1571,6 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": income_or_expense_account, - "against_type": against_type, "against": supplier_or_customer, "against_link": supplier_or_customer, rev_dr_cr: flt( @@ -1601,7 +1595,6 @@ class AccountsController(TransactionBase): self.get_gl_dict( { "account": self.additional_discount_account, - "against_type": against_type, "against": supplier_or_customer, "against_link": supplier_or_customer, dr_or_cr: self.base_discount_amount,