From d301d26fda50b85b79fd56c6883f865d6ff65f4c Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 31 Jul 2019 15:58:19 +0530 Subject: [PATCH] fix: Enhancement in credit note (#18511) * fix: Credit note enhancement * Fix: Print format for Sales Invoice Return * fix: Zero quantity validation fix for credit note --- .../doctype/sales_invoice/sales_invoice.js | 14 +- .../sales_invoice_return/__init__.py | 0 .../sales_invoice_return.html | 129 ++++++++++++++++++ .../sales_invoice_return.json | 24 ++++ erpnext/controllers/accounts_controller.py | 4 +- erpnext/controllers/taxes_and_totals.py | 7 +- .../public/js/controllers/taxes_and_totals.js | 8 +- 7 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 erpnext/accounts/print_format/sales_invoice_return/__init__.py create mode 100644 erpnext/accounts/print_format/sales_invoice_return/sales_invoice_return.html create mode 100644 erpnext/accounts/print_format/sales_invoice_return/sales_invoice_return.json diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 1fe6895601..74e9186e37 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -44,6 +44,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this.frm.toggle_reqd("due_date", !this.frm.doc.is_return); + if (this.frm.doc.is_return) { + this.frm.return_print_format = "Sales Invoice Return"; + } + this.show_general_ledger(); if(doc.update_stock) this.show_stock_ledger(); @@ -148,16 +152,24 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }, set_default_print_format: function() { - // set default print format to POS type + // set default print format to POS type or Credit Note if(cur_frm.doc.is_pos) { if(cur_frm.pos_print_format) { cur_frm.meta._default_print_format = cur_frm.meta.default_print_format; cur_frm.meta.default_print_format = cur_frm.pos_print_format; } + } else if(cur_frm.doc.is_return) { + if(cur_frm.return_print_format) { + cur_frm.meta._default_print_format = cur_frm.meta.default_print_format; + cur_frm.meta.default_print_format = cur_frm.return_print_format; + } } else { if(cur_frm.meta._default_print_format) { cur_frm.meta.default_print_format = cur_frm.meta._default_print_format; cur_frm.meta._default_print_format = null; + } else if(in_list([cur_frm.pos_print_format, cur_frm.return_print_format], cur_frm.meta.default_print_format)) { + cur_frm.meta.default_print_format = null; + cur_frm.meta._default_print_format = null; } } }, diff --git a/erpnext/accounts/print_format/sales_invoice_return/__init__.py b/erpnext/accounts/print_format/sales_invoice_return/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/accounts/print_format/sales_invoice_return/sales_invoice_return.html b/erpnext/accounts/print_format/sales_invoice_return/sales_invoice_return.html new file mode 100644 index 0000000000..889b7f71aa --- /dev/null +++ b/erpnext/accounts/print_format/sales_invoice_return/sales_invoice_return.html @@ -0,0 +1,129 @@ +{%- from "templates/print_formats/standard_macros.html" import add_header, render_field, print_value, fieldmeta, + get_width, get_align_class -%} + +{%- macro render_currency(df, doc) -%} +
{{ _("Sr") }} | + {% for tdf in visible_columns %} + {% if (data and not data[0].flags.compact_item_print) or tdf.fieldname in doc.get(df.fieldname)[0].flags.compact_item_fields %} ++ {{ _(tdf.label) }} | + {% endif %} + {% endfor %} +
---|---|
{{ d.idx }} | + {% for tdf in visible_columns %} + {% if not d.flags.compact_item_print or tdf.fieldname in doc.get(df.fieldname)[0].flags.compact_item_fields %} +
+ {% if tdf.fieldtype == 'Currency' %}
+ {{ frappe.utils.fmt_money((d[tdf.fieldname])|int|abs, currency=doc.currency) }} |
+ {% else %}
+