From 05f29988f42cd6cdf902a5b5ad2e6da43466d444 Mon Sep 17 00:00:00 2001 From: Saif Date: Mon, 27 May 2019 13:35:14 +0500 Subject: [PATCH] fix: Status updater for Credit/Debit Note Issued (#16998) * fix: Status updater for Credit/Debit Note Issued higher precendence than Return * style: linting --- .../purchase_invoice/purchase_invoice_list.js | 10 +++++----- .../accounts/doctype/sales_invoice/sales_invoice.py | 8 ++++---- .../doctype/sales_invoice/sales_invoice_list.js | 12 ++++++------ erpnext/controllers/status_updater.py | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js index 4103e57df86..4e76a8d9552 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js @@ -6,8 +6,8 @@ frappe.listview_settings['Purchase Invoice'] = { add_fields: ["supplier", "supplier_name", "base_grand_total", "outstanding_amount", "due_date", "company", "currency", "is_return", "release_date", "on_hold"], get_indicator: function(doc) { - if(cint(doc.is_return)==1) { - return [__("Return"), "darkgrey", "is_return,=,Yes"]; + if(flt(doc.outstanding_amount) < 0 && doc.docstatus == 1) { + return [__("Debit Note Issued"), "darkgrey", "outstanding_amount,<,0"] } else if(flt(doc.outstanding_amount) > 0 && doc.docstatus==1) { if(cint(doc.on_hold) && !doc.release_date) { return [__("On Hold"), "darkgrey"]; @@ -18,9 +18,9 @@ frappe.listview_settings['Purchase Invoice'] = { } else { return [__("Unpaid"), "orange", "outstanding_amount,>,0|due,>=,Today"]; } - } else if(flt(doc.outstanding_amount) < 0 && doc.docstatus == 1) { - return [__("Debit Note Issued"), "darkgrey", "outstanding_amount,<,0"] - }else if(flt(doc.outstanding_amount)==0 && doc.docstatus==1) { + } else if(cint(doc.is_return)) { + return [__("Return"), "darkgrey", "is_return,=,Yes"]; + } else if(flt(doc.outstanding_amount)==0 && doc.docstatus==1) { return [__("Paid"), "green", "outstanding_amount,=,0"]; } } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index fd49ce2ade9..ca94b52c532 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -54,8 +54,8 @@ class SalesInvoice(SellingController): def set_indicator(self): """Set indicator for portal""" - if cint(self.is_return) == 1: - self.indicator_title = _("Return") + if self.outstanding_amount < 0: + self.indicator_title = _("Credit Note Issued") self.indicator_color = "darkgrey" elif self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()): self.indicator_color = "orange" @@ -63,8 +63,8 @@ class SalesInvoice(SellingController): elif self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()): self.indicator_color = "red" self.indicator_title = _("Overdue") - elif self.outstanding_amount < 0: - self.indicator_title = _("Credit Note Issued") + elif cint(self.is_return) == 1: + self.indicator_title = _("Return") self.indicator_color = "darkgrey" else: self.indicator_color = "green" diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js index 3c9c4b428da..52d292430af 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js @@ -6,16 +6,16 @@ frappe.listview_settings['Sales Invoice'] = { add_fields: ["customer", "customer_name", "base_grand_total", "outstanding_amount", "due_date", "company", "currency", "is_return"], get_indicator: function(doc) { - if(cint(doc.is_return)==1) { - return [__("Return"), "darkgrey", "is_return,=,Yes"]; - } else if(flt(doc.outstanding_amount)==0) { - return [__("Paid"), "green", "outstanding_amount,=,0"] - } else if(flt(doc.outstanding_amount) < 0) { + if(flt(doc.outstanding_amount) < 0) { return [__("Credit Note Issued"), "darkgrey", "outstanding_amount,<,0"] - }else if (flt(doc.outstanding_amount) > 0 && doc.due_date >= frappe.datetime.get_today()) { + } else if (flt(doc.outstanding_amount) > 0 && doc.due_date >= frappe.datetime.get_today()) { return [__("Unpaid"), "orange", "outstanding_amount,>,0|due_date,>,Today"] } else if (flt(doc.outstanding_amount) > 0 && doc.due_date < frappe.datetime.get_today()) { return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<=,Today"] + } else if(cint(doc.is_return)) { + return [__("Return"), "darkgrey", "is_return,=,Yes"]; + } else if(flt(doc.outstanding_amount)==0) { + return [__("Paid"), "green", "outstanding_amount,=,0"] } }, right_column: "grand_total" diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index cb505189bdc..29bd014fc8d 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -45,9 +45,9 @@ status_map = { "Sales Invoice": [ ["Draft", None], ["Submitted", "eval:self.docstatus==1"], + ["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"], ["Return", "eval:self.is_return==1 and self.docstatus==1"], - ["Paid", "eval:self.outstanding_amount<=0 and self.docstatus==1 and self.is_return==0"], - ["Credit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1 and self.is_return==0 and get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"], + ["Credit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1"], ["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"], ["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"], ["Cancelled", "eval:self.docstatus==2"], @@ -55,9 +55,9 @@ status_map = { "Purchase Invoice": [ ["Draft", None], ["Submitted", "eval:self.docstatus==1"], + ["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"], ["Return", "eval:self.is_return==1 and self.docstatus==1"], - ["Paid", "eval:self.outstanding_amount<=0 and self.docstatus==1 and self.is_return==0"], - ["Debit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1 and self.is_return==0 and get_value('Purchase Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1})"], + ["Debit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1"], ["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"], ["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"], ["Cancelled", "eval:self.docstatus==2"],