[Fix] Showing to bill even if per deliverd in sales order is 99.9996 (#13392)

This commit is contained in:
rohitwaghchaure 2018-03-27 11:31:44 +05:30 committed by Nabin Hait
parent 149f7ee875
commit 85f63a3866
3 changed files with 14 additions and 14 deletions

View File

@ -285,7 +285,7 @@ class StatusUpdater(Document):
ifnull((select
ifnull(sum(if(%(target_ref_field)s > %(target_field)s, abs(%(target_field)s), abs(%(target_ref_field)s))), 0)
/ sum(abs(%(target_ref_field)s)) * 100
from `tab%(target_dt)s` where parent="%(name)s" having sum(abs(%(target_ref_field)s)) > 0), 0), 2)
from `tab%(target_dt)s` where parent="%(name)s" having sum(abs(%(target_ref_field)s)) > 0), 0), 6)
%(update_modified)s
where name='%(name)s'""" % args)
@ -293,7 +293,7 @@ class StatusUpdater(Document):
if args.get('status_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(status_field)s = if(%(target_parent_field)s<0.001,
'Not %(keyword)s', if(%(target_parent_field)s>=99.99,
'Not %(keyword)s', if(%(target_parent_field)s>=99.999999,
'Fully %(keyword)s', 'Partly %(keyword)s'))
where name='%(name)s'""" % args)

View File

@ -96,14 +96,14 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
if (this.frm.has_perm("submit")) {
// close
if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed) < 100) {
if(flt(doc.per_delivered, 6) < 100 || flt(doc.per_billed) < 100) {
this.frm.add_custom_button(__('Close'),
function() { me.close_sales_order() }, __("Status"))
}
}
// delivery note
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
if(flt(doc.per_delivered, 6) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1 && allow_delivery) {
this.frm.add_custom_button(__('Delivery'),
function() { me.make_delivery_note_based_on_delivery_date(); }, __("Make"));
this.frm.add_custom_button(__('Production Order'),
@ -113,20 +113,20 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
}
// sales invoice
if(flt(doc.per_billed, 2) < 100) {
if(flt(doc.per_billed, 6) < 100) {
this.frm.add_custom_button(__('Invoice'),
function() { me.make_sales_invoice() }, __("Make"));
}
// material request
if(!doc.order_type || ["Sales", "Shopping Cart"].indexOf(doc.order_type)!==-1
&& flt(doc.per_delivered, 2) < 100) {
&& flt(doc.per_delivered, 6) < 100) {
this.frm.add_custom_button(__('Material Request'),
function() { me.make_material_request() }, __("Make"));
}
// make purchase order
if(flt(doc.per_delivered, 2) < 100 && allow_purchase) {
if(flt(doc.per_delivered, 6) < 100 && allow_purchase) {
this.frm.add_custom_button(__('Purchase Order'),
function() { me.make_purchase_order() }, __("Make"));
}

View File

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