diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 15468575cdd..95e1ccf132b 100755 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -2787,7 +2787,7 @@ "label": "Status", "length": 0, "no_copy": 0, - "options": "\nDraft\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled", + "options": "\nDraft\nReturn\nDebit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled", "permlevel": 0, "precision": "", "print_hide": 0, @@ -3293,7 +3293,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-11-08 11:49:00.752417", + "modified": "2016-11-09 14:18:47.094777", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js index afcd61f228e..8283acc4f12 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js @@ -14,7 +14,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) { + } 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) { return [__("Paid"), "green", "outstanding_amount,=,0"]; } } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index b4747cecd58..216b73ac7ff 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -3081,7 +3081,7 @@ "label": "Status", "length": 0, "no_copy": 1, - "options": "\nDraft\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled", + "options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled", "permlevel": 0, "precision": "", "print_hide": 1, @@ -4039,7 +4039,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-11-08 11:47:43.494612", + "modified": "2016-11-09 14:18:24.760263", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js index 5e21d7abefe..3c9c4b428da 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js @@ -10,7 +10,9 @@ frappe.listview_settings['Sales Invoice'] = { 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 && doc.due_date >= frappe.datetime.get_today()) { + } else 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()) { 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"] diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index cb783b4db34..fcddc8fb3df 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -44,7 +44,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"], + ["Credit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1"], + ["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1 and self.is_return==0"], ["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"], @@ -52,7 +54,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"], + ["Debit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1"], + ["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1 and self.is_return==0"], ["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"], diff --git a/erpnext/patches/v7_1/update_invoice_status.py b/erpnext/patches/v7_1/update_invoice_status.py index 5a2d013f318..851af80f7a2 100644 --- a/erpnext/patches/v7_1/update_invoice_status.py +++ b/erpnext/patches/v7_1/update_invoice_status.py @@ -12,9 +12,11 @@ def execute(): update `tabPurchase Invoice` set - status = (Case When outstanding_amount = 0 and docstatus = 1 then 'Paid' + status = (Case When outstanding_amount = 0 and docstatus = 1 and is_return = 0 then 'Paid' when due_date < CURDATE() and outstanding_amount > 0 and docstatus =1 then 'Overdue' when due_date >= CURDATE() and outstanding_amount > 0 and docstatus =1 then 'Unpaid' + when outstanding_amount < 0 and docstatus =1 then 'Debit Note Issued' + when is_return = 1 and docstatus =1 then 'Return' when docstatus = 2 then 'Cancelled' else 'Draft' End)""") @@ -22,9 +24,11 @@ def execute(): frappe.db.sql(""" update `tabSales Invoice` - set status = (Case When outstanding_amount = 0 and docstatus = 1 then 'Paid' + set status = (Case When outstanding_amount = 0 and docstatus = 1 and is_return = 0 then 'Paid' when due_date < CURDATE() and outstanding_amount > 0 and docstatus =1 then 'Overdue' when due_date >= CURDATE() and outstanding_amount > 0 and docstatus =1 then 'Unpaid' + when outstanding_amount < 0 and docstatus =1 then 'Credit Note Issued' + when is_return = 1 and docstatus =1 then 'Return' when docstatus = 2 then 'Cancelled' else 'Draft' End)""") \ No newline at end of file