refactor: better abstraction for controller code
This commit is contained in:
parent
e4d657e6fd
commit
9ab55a5bd8
@ -536,6 +536,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
"cash_bank_account",
|
"cash_bank_account",
|
||||||
"write_off_account",
|
"write_off_account",
|
||||||
"unrealized_profit_loss_account",
|
"unrealized_profit_loss_account",
|
||||||
|
"is_opening",
|
||||||
]
|
]
|
||||||
child_tables = {"items": ("expense_account",), "taxes": ("account_head",)}
|
child_tables = {"items": ("expense_account",), "taxes": ("account_head",)}
|
||||||
self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables)
|
self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables)
|
||||||
|
|||||||
@ -530,6 +530,7 @@ class SalesInvoice(SellingController):
|
|||||||
"write_off_account",
|
"write_off_account",
|
||||||
"loyalty_redemption_account",
|
"loyalty_redemption_account",
|
||||||
"unrealized_profit_loss_account",
|
"unrealized_profit_loss_account",
|
||||||
|
"is_opening",
|
||||||
]
|
]
|
||||||
child_tables = {
|
child_tables = {
|
||||||
"items": ("income_account", "expense_account", "discount_account"),
|
"items": ("income_account", "expense_account", "discount_account"),
|
||||||
|
|||||||
@ -2216,27 +2216,20 @@ class AccountsController(TransactionBase):
|
|||||||
doc_before_update = self.get_doc_before_save()
|
doc_before_update = self.get_doc_before_save()
|
||||||
accounting_dimensions = get_accounting_dimensions() + ["cost_center", "project"]
|
accounting_dimensions = get_accounting_dimensions() + ["cost_center", "project"]
|
||||||
|
|
||||||
# Check if opening entry check updated
|
|
||||||
needs_repost = doc_before_update.get("is_opening") != self.is_opening
|
|
||||||
|
|
||||||
if not needs_repost:
|
|
||||||
# Parent Level Accounts excluding party account
|
# Parent Level Accounts excluding party account
|
||||||
fields_to_check += accounting_dimensions
|
fields_to_check += accounting_dimensions
|
||||||
for field in fields_to_check:
|
for field in fields_to_check:
|
||||||
if doc_before_update.get(field) != self.get(field):
|
if doc_before_update.get(field) != self.get(field):
|
||||||
needs_repost = 1
|
return True
|
||||||
break
|
|
||||||
|
|
||||||
if not needs_repost:
|
|
||||||
# Check for child tables
|
# Check for child tables
|
||||||
for table in child_tables:
|
for table in child_tables:
|
||||||
needs_repost = check_if_child_table_updated(
|
if check_if_child_table_updated(
|
||||||
doc_before_update.get(table), self.get(table), child_tables[table]
|
doc_before_update.get(table), self.get(table), child_tables[table]
|
||||||
)
|
):
|
||||||
if needs_repost:
|
return True
|
||||||
break
|
|
||||||
|
|
||||||
return needs_repost
|
return False
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def repost_accounting_entries(self):
|
def repost_accounting_entries(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user