refactor: restrict to 'Advance in Separate Party Account' type

(cherry picked from commit c36f0e4a33)
This commit is contained in:
ruthra kumar
2024-05-31 17:11:40 +05:30
committed by Mergify
parent c664a27b1e
commit 1fc802da6f
2 changed files with 6 additions and 1 deletions

View File

@@ -781,6 +781,7 @@
}, },
{ {
"default": "No", "default": "No",
"depends_on": "eval: doc.book_advance_payments_in_separate_party_account == 1",
"fieldname": "is_opening", "fieldname": "is_opening",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Is Opening", "label": "Is Opening",
@@ -800,7 +801,7 @@
"table_fieldname": "payment_entries" "table_fieldname": "payment_entries"
} }
], ],
"modified": "2024-05-31 16:54:59.618516", "modified": "2024-05-31 17:07:06.197249",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Payment Entry", "name": "Payment Entry",

View File

@@ -116,11 +116,13 @@ class PaymentEntry(AccountsController):
self.book_advance_payments_in_separate_party_account = False self.book_advance_payments_in_separate_party_account = False
if self.party_type not in ("Customer", "Supplier"): if self.party_type not in ("Customer", "Supplier"):
self.is_opening = "No"
return return
if not frappe.db.get_value( if not frappe.db.get_value(
"Company", self.company, "book_advance_payments_in_separate_party_account" "Company", self.company, "book_advance_payments_in_separate_party_account"
): ):
self.is_opening = "No"
return return
# Important to set this flag for the gl building logic to work properly # Important to set this flag for the gl building logic to work properly
@@ -132,6 +134,7 @@ class PaymentEntry(AccountsController):
if (account_type == "Payable" and self.party_type == "Customer") or ( if (account_type == "Payable" and self.party_type == "Customer") or (
account_type == "Receivable" and self.party_type == "Supplier" account_type == "Receivable" and self.party_type == "Supplier"
): ):
self.is_opening = "No"
return return
if self.references: if self.references:
@@ -141,6 +144,7 @@ class PaymentEntry(AccountsController):
# If there are referencers other than `allowed_types`, treat this as a normal payment entry # If there are referencers other than `allowed_types`, treat this as a normal payment entry
if reference_types - allowed_types: if reference_types - allowed_types:
self.book_advance_payments_in_separate_party_account = False self.book_advance_payments_in_separate_party_account = False
self.is_opening = "No"
return return
liability_account = get_party_account( liability_account = get_party_account(