diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index de99c35e27e..623fb941b89 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -285,7 +285,6 @@ class PurchaseInvoice(BuyingController): self.set_against_expense_account() self.validate_write_off_account() self.validate_multiple_billing("Purchase Receipt", "pr_detail", "amount") - self.create_remarks() self.set_status() self.validate_purchase_receipt_if_update_stock() validate_inter_company_party( @@ -322,10 +321,11 @@ class PurchaseInvoice(BuyingController): def create_remarks(self): if not self.remarks: - if self.bill_no and self.bill_date: - self.remarks = _("Against Supplier Invoice {0} dated {1}").format( - self.bill_no, formatdate(self.bill_date) - ) + if self.bill_no: + self.remarks = _("Against Supplier Invoice {0}").format(self.bill_no) + if self.bill_date: + self.remarks += " " + _("dated {0}").format(formatdate(self.bill_date)) + else: self.remarks = _("No Remarks") @@ -747,6 +747,9 @@ class PurchaseInvoice(BuyingController): validate_docs_for_voucher_types(["Purchase Invoice"]) validate_docs_for_deferred_accounting([], [self.name]) + def before_submit(self): + self.create_remarks() + def on_submit(self): super().on_submit() diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 1966a78ef49..12e26623ad0 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -278,7 +278,6 @@ class SalesInvoice(SellingController): self.check_sales_order_on_hold_or_close("sales_order") self.validate_debit_to_acc() self.clear_unallocated_advances("Sales Invoice Advance", "advances") - self.add_remarks() self.validate_fixed_asset() self.set_income_account_for_fixed_assets() self.validate_item_cost_centers() @@ -422,6 +421,9 @@ class SalesInvoice(SellingController): self.set_account_for_mode_of_payment() self.set_paid_amount() + def before_submit(self): + self.add_remarks() + def on_submit(self): self.validate_pos_paid_amount() @@ -946,10 +948,11 @@ class SalesInvoice(SellingController): def add_remarks(self): if not self.remarks: - if self.po_no and self.po_date: - self.remarks = _("Against Customer Order {0} dated {1}").format( - self.po_no, formatdate(self.po_date) - ) + if self.po_no: + self.remarks = _("Against Customer Order {0}").format(self.po_no) + if self.po_date: + self.remarks += " " + _("dated {0}").format(formatdate(self.po_data)) + else: self.remarks = _("No Remarks") diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html index 3c4e1a05c97..bdea568bdf4 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.html +++ b/erpnext/accounts/report/general_ledger/general_ledger.html @@ -48,8 +48,9 @@
{% } %} -
{%= __("Remarks") %}: {%= data[i].remarks %} - {% if(data[i].bill_no) { %} + {% if(data[i].remarks) { %} +
{%= __("Remarks") %}: {%= data[i].remarks %} + {% } else if(data[i].bill_no) { %}
{%= __("Supplier Invoice No") %}: {%= data[i].bill_no %} {% } %} diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 7350fa77e1c..5b1455ef723 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -371,6 +371,7 @@ erpnext.patches.v15_0.update_warehouse_field_in_asset_repair_consumed_item_docty erpnext.patches.v15_0.update_asset_repair_field_in_stock_entry erpnext.patches.v15_0.update_total_number_of_booked_depreciations erpnext.patches.v15_0.do_not_use_batchwise_valuation +erpnext.patches.v15_0.update_invoice_remarks erpnext.patches.v14_0.update_reports_with_range erpnext.patches.v15_0.drop_index_posting_datetime_from_sle erpnext.patches.v15_0.add_disassembly_order_stock_entry_type #1 diff --git a/erpnext/patches/v15_0/update_invoice_remarks.py b/erpnext/patches/v15_0/update_invoice_remarks.py new file mode 100644 index 00000000000..7060fe57e31 --- /dev/null +++ b/erpnext/patches/v15_0/update_invoice_remarks.py @@ -0,0 +1,51 @@ +import frappe +from frappe import _ + + +def execute(): + update_sales_invoice_remarks() + update_purchase_invoice_remarks() + + +def update_sales_invoice_remarks(): + si_list = frappe.db.get_all( + "Sales Invoice", + filters={ + "docstatus": 1, + "remarks": "No Remarks", + "po_no": ["!=", ""], + }, + fields=["name", "po_no"], + ) + + for doc in si_list: + remarks = _("Against Customer Order {0}").format(doc.po_no) + update_remarks("Sales Invoice", doc.name, remarks) + + +def update_purchase_invoice_remarks(): + pi_list = frappe.db.get_all( + "Purchase Invoice", + filters={ + "docstatus": 1, + "remarks": "No Remarks", + "bill_no": ["!=", ""], + }, + fields=["name", "bill_no"], + ) + + for doc in pi_list: + remarks = _("Against Supplier Invoice {0}").format(doc.bill_no) + update_remarks("Purchase Invoice", doc.name, remarks) + + +def update_remarks(doctype, docname, remarks): + filters = { + "voucher_type": doctype, + "remarks": "No Remarks", + "voucher_no": docname, + } + + frappe.db.set_value(doctype, docname, "remarks", remarks) + frappe.db.set_value("GL Entry", filters, "remarks", remarks) + frappe.db.set_value("Payment Ledger Entry", filters, "remarks", remarks)