[Fix] 'To Bill' status even if the amount is zero (#14784)

* Fix 'To Bill' status even if the invoice amount is zero

* Modify fix to only apply on Delivery Note documents
This commit is contained in:
Alchez 2018-09-06 18:27:06 +05:30 committed by Nabin Hait
parent a2a6568b7e
commit e52ae4eacb
5 changed files with 32 additions and 31 deletions

View File

@ -335,8 +335,7 @@ class StatusUpdater(Document):
from `tab%s Item` where %s=%s and docstatus=1""" %
(self.doctype, ref_fieldname, '%s'), (ref_dn))[0][0])
per_billed = ((ref_doc_qty if billed_qty > ref_doc_qty else billed_qty)\
/ ref_doc_qty)*100
per_billed = (min(ref_doc_qty, billed_qty) / ref_doc_qty) * 100
ref_doc = frappe.get_doc(ref_dt, ref_dn)

View File

@ -7,14 +7,19 @@ frappe.listview_settings['Sales Order'] = {
} else if (doc.order_type !== "Maintenance"
&& flt(doc.per_delivered, 6) < 100 && frappe.datetime.get_diff(doc.delivery_date) < 0) {
// to bill & overdue
// not delivered & overdue
return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Closed"];
} else if (doc.order_type !== "Maintenance"
&& flt(doc.per_delivered, 6) < 100 && doc.status !== "Closed") {
// not delivered
if(flt(doc.per_billed, 6) < 100) {
if (flt(doc.grand_total) === 0) {
// not delivered (zero-amount order)
return [__("To Deliver"), "orange",
"per_delivered,<,100|grand_total,=,0|status,!=,Closed"];
} else if (flt(doc.per_billed, 6) < 100) {
// not delivered & not billed
return [__("To Deliver and Bill"), "orange",
@ -27,13 +32,13 @@ frappe.listview_settings['Sales Order'] = {
}
} else if ((doc.order_type === "Maintenance" || flt(doc.per_delivered, 6) == 100)
&& flt(doc.per_billed, 6) < 100 && doc.status!=="Closed") {
&& flt(doc.grand_total) !== 0 && flt(doc.per_billed, 6) < 100 && doc.status !== "Closed") {
// to bill
return [__("To Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Closed"];
} else if ((doc.order_type === "Maintenance" || flt(doc.per_delivered, 6) == 100)
&& flt(doc.per_billed, 6) == 100 && doc.status!=="Closed") {
&& (flt(doc.grand_total) === 0 || flt(doc.per_billed, 6) == 100) && doc.status !== "Closed") {
return [__("Completed"), "green", "per_delivered,=,100|per_billed,=,100|status,!=,Closed"];
}

View File

@ -311,7 +311,6 @@ class DeliveryNote(SellingController):
for dn in set(updated_delivery_notes):
dn_doc = self if (dn == self.name) else frappe.get_doc("Delivery Note", dn)
if dn_doc.net_total > 0:
dn_doc.update_billing_percentage(update_modified=update_modified)
self.load_from_db()

View File

@ -1,14 +1,13 @@
frappe.listview_settings['Delivery Note'] = {
add_fields: ["customer", "customer_name", "base_grand_total", "per_installed", "per_billed",
"transporter_name", "grand_total", "is_return", "status"],
add_fields: ["grand_total", "is_return", "per_billed", "status"],
get_indicator: function (doc) {
if (cint(doc.is_return) == 1) {
return [__("Return"), "darkgrey", "is_return,=,Yes"];
} else if (doc.status === "Closed") {
return [__("Closed"), "green", "status,=,Closed"];
} else if (flt(doc.per_billed, 2) < 100) {
} else if (doc.grand_total !== 0 && flt(doc.per_billed, 2) < 100) {
return [__("To Bill"), "orange", "per_billed,<,100"];
} else if (flt(doc.per_billed, 2) == 100) {
} else if (doc.grand_total === 0 || flt(doc.per_billed, 2) == 100) {
return [__("Completed"), "green", "per_billed,=,100"];
}
}

View File

@ -1,14 +1,13 @@
frappe.listview_settings['Purchase Receipt'] = {
add_fields: ["supplier", "supplier_name", "base_grand_total", "is_subcontracted",
"transporter_name", "is_return", "status", "per_billed"],
add_fields: ["is_return", "grand_total", "status", "per_billed"],
get_indicator: function (doc) {
if (cint(doc.is_return) == 1) {
return [__("Return"), "darkgrey", "is_return,=,Yes"];
} else if (doc.status === "Closed") {
return [__("Closed"), "green", "status,=,Closed"];
} else if (flt(doc.per_billed, 2) < 100) {
} else if (flt(doc.grand_total) !== 0 && flt(doc.per_billed, 2) < 100) {
return [__("To Bill"), "orange", "per_billed,<,100"];
} else if (flt(doc.per_billed, 2) == 100) {
} else if (flt(doc.grand_total) === 0 || flt(doc.per_billed, 2) == 100) {
return [__("Completed"), "green", "per_billed,=,100"];
}
}