From 9b52d89e034f80f63973dc94220ca670dfdb840c Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:29:30 +0530 Subject: [PATCH 1/9] chore: remove stale code from sales invoice (cherry picked from commit f3fda9ce989f98aa971537799afa9ecf5b848547) --- .../doctype/sales_invoice/sales_invoice.js | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 797d00fe3ec..d463ecd5570 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -68,31 +68,6 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends ( this.frm.toggle_reqd("due_date", !this.frm.doc.is_return); - if (this.frm.doc.repost_required && this.frm.doc.docstatus === 1) { - this.frm.set_intro( - __( - "Accounting entries for this invoice needs to be reposted. Please click on 'Repost' button to update." - ) - ); - this.frm - .add_custom_button(__("Repost Accounting Entries"), () => { - this.frm.call({ - doc: this.frm.doc, - method: "repost_accounting_entries", - freeze: true, - freeze_message: __("Reposting..."), - callback: (r) => { - if (!r.exc) { - frappe.msgprint(__("Accounting Entries are reposted")); - me.frm.refresh(); - } - }, - }); - }) - .removeClass("btn-default") - .addClass("btn-warning"); - } - if (this.frm.doc.is_return) { this.frm.return_print_format = "Sales Invoice Return"; } From a8fe0e89a8bff3317d679e85e10d1cf4e6602cbe Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:31:01 +0530 Subject: [PATCH 2/9] chore: remove stale 'repost_required' flag from sales invoice (cherry picked from commit 06c5334f2a6db3114b675dbf393abe94afe9bdb7) # Conflicts: # erpnext/accounts/doctype/sales_invoice/sales_invoice.json --- .../doctype/sales_invoice/sales_invoice.json | 14 ++++---------- .../doctype/sales_invoice/sales_invoice.py | 1 - 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 90b6e768092..ac2047a54fd 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -213,7 +213,6 @@ "is_internal_customer", "is_discounted", "remarks", - "repost_required", "connections_tab" ], "fields": [ @@ -2125,15 +2124,6 @@ "label": "Write Off", "width": "50%" }, - { - "default": "0", - "fieldname": "repost_required", - "fieldtype": "Check", - "hidden": 1, - "label": "Repost Required", - "no_copy": 1, - "read_only": 1 - }, { "fieldname": "incoterm", "fieldtype": "Link", @@ -2188,7 +2178,11 @@ "link_fieldname": "consolidated_invoice" } ], +<<<<<<< HEAD "modified": "2024-06-07 16:49:32.458402", +======= + "modified": "2024-07-18 15:30:39.428519", +>>>>>>> 06c5334f2a (chore: remove stale 'repost_required' flag from sales invoice) "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 0d48cf229e5..7eb3cccbc72 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -161,7 +161,6 @@ class SalesInvoice(SellingController): project: DF.Link | None redeem_loyalty_points: DF.Check remarks: DF.SmallText | None - repost_required: DF.Check represents_company: DF.Link | None return_against: DF.Link | None rounded_total: DF.Currency From 3d8eac9b5aa37569fea0988a44141fd648728e20 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:31:59 +0530 Subject: [PATCH 3/9] chore: remove 'repost_required' from purchase invoice (cherry picked from commit a467888a67088e1a7997bf5d2b800817e64b08cb) --- .../doctype/purchase_invoice/purchase_invoice.json | 12 +----------- .../doctype/purchase_invoice/purchase_invoice.py | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index cf08d08ce4b..79863d0e338 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -170,7 +170,6 @@ "against_expense_account", "column_break_63", "unrealized_profit_loss_account", - "repost_required", "subscription_section", "subscription", "auto_repeat", @@ -1603,15 +1602,6 @@ "fieldtype": "Check", "label": "Use Company Default Round Off Cost Center" }, - { - "default": "0", - "fieldname": "repost_required", - "fieldtype": "Check", - "hidden": 1, - "label": "Repost Required", - "options": "Account", - "read_only": 1 - }, { "default": "0", "fieldname": "use_transaction_date_exchange_rate", @@ -1639,7 +1629,7 @@ "idx": 204, "is_submittable": 1, "links": [], - "modified": "2024-04-11 11:28:42.802211", + "modified": "2024-07-18 15:31:49.488566", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 15f53d996da..7d1e3ac2f31 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -159,7 +159,6 @@ class PurchaseInvoice(BuyingController): rejected_warehouse: DF.Link | None release_date: DF.Date | None remarks: DF.SmallText | None - repost_required: DF.Check represents_company: DF.Link | None return_against: DF.Link | None rounded_total: DF.Currency From 8b9860902cac01380cb10da970c839ef0f7f7e0c Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:32:51 +0530 Subject: [PATCH 4/9] chore: remove 'repost_required' from Journal Entry (cherry picked from commit e81373bb6ae1bde6c5b3261f776ba647cd9b65e3) # Conflicts: # erpnext/accounts/doctype/journal_entry/journal_entry.json --- .../doctype/journal_entry/journal_entry.json | 16 +++++----------- .../doctype/journal_entry/journal_entry.py | 4 +--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json index 91febb34052..021c9e19c15 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.json +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json @@ -64,8 +64,7 @@ "stock_entry", "subscription_section", "auto_repeat", - "amended_from", - "repost_required" + "amended_from" ], "fields": [ { @@ -544,15 +543,6 @@ "label": "Is System Generated", "no_copy": 1, "read_only": 1 - }, - { - "default": "0", - "fieldname": "repost_required", - "fieldtype": "Check", - "hidden": 1, - "label": "Repost Required", - "print_hide": 1, - "read_only": 1 } ], "icon": "fa fa-file-text", @@ -567,7 +557,11 @@ "table_fieldname": "payment_entries" } ], +<<<<<<< HEAD "modified": "2023-11-23 12:11:04.128015", +======= + "modified": "2024-07-18 15:32:29.413598", +>>>>>>> e81373bb6a (chore: remove 'repost_required' from Journal Entry) "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry", diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 12b9800e688..07794eb2fd3 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -47,9 +47,7 @@ class JournalEntry(AccountsController): if TYPE_CHECKING: from frappe.types import DF - from erpnext.accounts.doctype.journal_entry_account.journal_entry_account import ( - JournalEntryAccount, - ) + from erpnext.accounts.doctype.journal_entry_account.journal_entry_account import JournalEntryAccount accounts: DF.Table[JournalEntryAccount] amended_from: DF.Link | None From 01dfea3ffab90759f72c23c25e19bd975b6d8b33 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:34:02 +0530 Subject: [PATCH 5/9] chore: remove stale UI code related to repost (cherry picked from commit fe46e1d0899724efdbbdd32881be62112b97c11c) --- .../doctype/journal_entry/journal_entry.js | 24 ------------------ .../purchase_invoice/purchase_invoice.js | 25 ------------------- 2 files changed, 49 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 2c831cf7c57..d290d794df1 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -25,30 +25,6 @@ frappe.ui.form.on("Journal Entry", { refresh: function (frm) { erpnext.toggle_naming_series(); - if (frm.doc.repost_required && frm.doc.docstatus === 1) { - frm.set_intro( - __( - "Accounting entries for this Journal Entry need to be reposted. Please click on 'Repost' button to update." - ) - ); - frm.add_custom_button(__("Repost Accounting Entries"), () => { - frm.call({ - doc: frm.doc, - method: "repost_accounting_entries", - freeze: true, - freeze_message: __("Reposting..."), - callback: (r) => { - if (!r.exc) { - frappe.msgprint(__("Accounting Entries are reposted.")); - frm.refresh(); - } - }, - }); - }) - .removeClass("btn-default") - .addClass("btn-warning"); - } - if (frm.doc.docstatus > 0) { frm.add_custom_button( __("Ledger"), diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index c0a43395216..9c8c8cdfb03 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -77,31 +77,6 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. erpnext.accounts.ledger_preview.show_stock_ledger_preview(this.frm); } - if (this.frm.doc.repost_required && this.frm.doc.docstatus === 1) { - this.frm.set_intro( - __( - "Accounting entries for this invoice need to be reposted. Please click on 'Repost' button to update." - ) - ); - this.frm - .add_custom_button(__("Repost Accounting Entries"), () => { - this.frm.call({ - doc: this.frm.doc, - method: "repost_accounting_entries", - freeze: true, - freeze_message: __("Reposting..."), - callback: (r) => { - if (!r.exc) { - frappe.msgprint(__("Accounting Entries are reposted.")); - me.frm.refresh(); - } - }, - }); - }) - .removeClass("btn-default") - .addClass("btn-warning"); - } - if (!doc.is_return && doc.docstatus == 1 && doc.outstanding_amount != 0) { if (doc.on_hold) { this.frm.add_custom_button( From 949d7f4b532cc99ee0a12fd0094f616a11c4c379 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:34:59 +0530 Subject: [PATCH 6/9] refactor: repost without checking on flag (cherry picked from commit 09f429ffba15f1b9cd43ad8967efd71eb95b963c) --- erpnext/controllers/accounts_controller.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 0cbf1b320ca..67bfc71ed5b 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2489,16 +2489,12 @@ class AccountsController(TransactionBase): @frappe.whitelist() def repost_accounting_entries(self): - if self.repost_required: - repost_ledger = frappe.new_doc("Repost Accounting Ledger") - repost_ledger.company = self.company - repost_ledger.append("vouchers", {"voucher_type": self.doctype, "voucher_no": self.name}) - repost_ledger.flags.ignore_permissions = True - repost_ledger.insert() - repost_ledger.submit() - self.db_set("repost_required", 0) - else: - frappe.throw(_("No updates pending for reposting")) + repost_ledger = frappe.new_doc("Repost Accounting Ledger") + repost_ledger.company = self.company + repost_ledger.append("vouchers", {"voucher_type": self.doctype, "voucher_no": self.name}) + repost_ledger.flags.ignore_permissions = True + repost_ledger.insert() + repost_ledger.submit() @frappe.whitelist() From d69361b1c95bceb170f56ba42168517bde88cc0c Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:38:15 +0530 Subject: [PATCH 7/9] refactor: remove attribute check on 'repost_required' (cherry picked from commit 07fc952a4383de79ee7c327719047b7c7e02dcd7) --- .../doctype/journal_entry/journal_entry.py | 12 ++---- .../purchase_invoice/purchase_invoice.py | 24 ++++++------ .../doctype/sales_invoice/sales_invoice.py | 37 +++++++++---------- 3 files changed, 32 insertions(+), 41 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index 07794eb2fd3..6adc8be3f7d 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -195,14 +195,10 @@ class JournalEntry(AccountsController): self.update_booked_depreciation() def on_update_after_submit(self): - if hasattr(self, "repost_required"): - self.needs_repost = self.check_if_fields_updated( - fields_to_check=[], child_tables={"accounts": []} - ) - if self.needs_repost: - self.validate_for_repost() - self.db_set("repost_required", self.needs_repost) - self.repost_accounting_entries() + self.needs_repost = self.check_if_fields_updated(fields_to_check=[], child_tables={"accounts": []}) + if self.needs_repost: + self.validate_for_repost() + self.repost_accounting_entries() def on_cancel(self): # References for this Journal are removed on the `on_cancel` event in accounts_controller diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 7d1e3ac2f31..111886048ce 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -795,19 +795,17 @@ class PurchaseInvoice(BuyingController): self.process_common_party_accounting() def on_update_after_submit(self): - if hasattr(self, "repost_required"): - fields_to_check = [ - "cash_bank_account", - "write_off_account", - "unrealized_profit_loss_account", - "is_opening", - ] - child_tables = {"items": ("expense_account",), "taxes": ("account_head",)} - self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) - if self.needs_repost: - self.validate_for_repost() - self.db_set("repost_required", self.needs_repost) - self.repost_accounting_entries() + fields_to_check = [ + "cash_bank_account", + "write_off_account", + "unrealized_profit_loss_account", + "is_opening", + ] + child_tables = {"items": ("expense_account",), "taxes": ("account_head",)} + self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) + if self.needs_repost: + self.validate_for_repost() + self.repost_accounting_entries() def make_gl_entries(self, gl_entries=None, from_repost=False): update_outstanding = "No" if (cint(self.is_paid) or self.write_off_account) else "Yes" diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 7eb3cccbc72..24e61b0d221 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -555,7 +555,6 @@ class SalesInvoice(SellingController): self.repost_future_sle_and_gle() self.db_set("status", "Cancelled") - self.db_set("repost_required", 0) if frappe.db.get_single_value("Selling Settings", "sales_update_frequency") == "Each Transaction": update_company_current_month_sales(self.company) @@ -705,25 +704,23 @@ class SalesInvoice(SellingController): data.sales_invoice = sales_invoice def on_update_after_submit(self): - if hasattr(self, "repost_required"): - fields_to_check = [ - "additional_discount_account", - "cash_bank_account", - "account_for_change_amount", - "write_off_account", - "loyalty_redemption_account", - "unrealized_profit_loss_account", - "is_opening", - ] - child_tables = { - "items": ("income_account", "expense_account", "discount_account"), - "taxes": ("account_head",), - } - self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) - if self.needs_repost: - self.validate_for_repost() - self.db_set("repost_required", self.needs_repost) - self.repost_accounting_entries() + fields_to_check = [ + "additional_discount_account", + "cash_bank_account", + "account_for_change_amount", + "write_off_account", + "loyalty_redemption_account", + "unrealized_profit_loss_account", + "is_opening", + ] + child_tables = { + "items": ("income_account", "expense_account", "discount_account"), + "taxes": ("account_head",), + } + self.needs_repost = self.check_if_fields_updated(fields_to_check, child_tables) + if self.needs_repost: + self.validate_for_repost() + self.repost_accounting_entries() def set_paid_amount(self): paid_amount = 0.0 From e607f3c78dde5edb4dba8761955c0b19b880ccbb Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 18 Jul 2024 15:39:30 +0530 Subject: [PATCH 8/9] refactor(test): remove assert on 'repost_required' (cherry picked from commit e71cb4eab7f07cad2f4245778a205750e5f0d768) --- .../accounts/doctype/purchase_invoice/test_purchase_invoice.py | 2 -- erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py | 3 --- 2 files changed, 5 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 68e9d2b0e00..eb7c486f2e1 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -2014,8 +2014,6 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): ["Service - _TC", 1000, 0.0, nowdate()], ] check_gl_entries(self, pi.name, expected_gle, nowdate()) - pi.load_from_db() - self.assertFalse(pi.repost_required) @change_settings("Buying Settings", {"supplier_group": None}) def test_purchase_invoice_without_supplier_group(self): diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index ee4e82b4dfa..9197f2e091a 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -2952,9 +2952,6 @@ class TestSalesInvoice(FrappeTestCase): check_gl_entries(self, si.name, expected_gle, add_days(nowdate(), -1)) - si.load_from_db() - self.assertFalse(si.repost_required) - def test_asset_depreciation_on_sale_with_pro_rata(self): """ Tests if an Asset set to depreciate yearly on June 30, that gets sold on Sept 30, creates an additional depreciation entry on its date of sale. From 2ae94b2af28cf40b3c66236a01104c0bb0fdb0fc Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 24 Jul 2024 13:01:51 +0530 Subject: [PATCH 9/9] chore: resolve conflicts --- erpnext/accounts/doctype/journal_entry/journal_entry.json | 6 +----- erpnext/accounts/doctype/sales_invoice/sales_invoice.json | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.json b/erpnext/accounts/doctype/journal_entry/journal_entry.json index 021c9e19c15..4184bdaabb9 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.json +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.json @@ -557,11 +557,7 @@ "table_fieldname": "payment_entries" } ], -<<<<<<< HEAD - "modified": "2023-11-23 12:11:04.128015", -======= "modified": "2024-07-18 15:32:29.413598", ->>>>>>> e81373bb6a (chore: remove 'repost_required' from Journal Entry) "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry", @@ -612,4 +608,4 @@ "states": [], "title_field": "title", "track_changes": 1 -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index ac2047a54fd..c44afd555e0 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -2178,11 +2178,7 @@ "link_fieldname": "consolidated_invoice" } ], -<<<<<<< HEAD - "modified": "2024-06-07 16:49:32.458402", -======= "modified": "2024-07-18 15:30:39.428519", ->>>>>>> 06c5334f2a (chore: remove stale 'repost_required' flag from sales invoice) "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice",