mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-18 17:55:40 +00:00
fix: remove field precision in SO and PO for percentage fields
(cherry picked from commit eff9cd10cd)
# Conflicts:
# erpnext/selling/doctype/sales_order/sales_order_list.js
This commit is contained in:
@@ -93,10 +93,7 @@ frappe.ui.form.on("Purchase Order", {
|
|||||||
get_materials_from_supplier: function (frm) {
|
get_materials_from_supplier: function (frm) {
|
||||||
let po_details = [];
|
let po_details = [];
|
||||||
|
|
||||||
if (
|
if (frm.doc.supplied_items && (flt(frm.doc.per_received) == 100 || frm.doc.status === "Closed")) {
|
||||||
frm.doc.supplied_items &&
|
|
||||||
(flt(frm.doc.per_received, precision("per_received")) == 100 || frm.doc.status === "Closed")
|
|
||||||
) {
|
|
||||||
frm.doc.supplied_items.forEach((d) => {
|
frm.doc.supplied_items.forEach((d) => {
|
||||||
if (d.total_supplied_qty && d.total_supplied_qty != d.consumed_qty) {
|
if (d.total_supplied_qty && d.total_supplied_qty != d.consumed_qty) {
|
||||||
po_details.push(d.name);
|
po_details.push(d.name);
|
||||||
@@ -332,8 +329,8 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
if (!["Closed", "Delivered"].includes(doc.status)) {
|
if (!["Closed", "Delivered"].includes(doc.status)) {
|
||||||
if (
|
if (
|
||||||
this.frm.doc.status !== "Closed" &&
|
this.frm.doc.status !== "Closed" &&
|
||||||
flt(this.frm.doc.per_received, precision("per_received")) < 100 &&
|
flt(this.frm.doc.per_received) < 100 &&
|
||||||
flt(this.frm.doc.per_billed, precision("per_billed")) < 100
|
flt(this.frm.doc.per_billed) < 100
|
||||||
) {
|
) {
|
||||||
if (!this.frm.doc.__onload || this.frm.doc.__onload.can_update_items) {
|
if (!this.frm.doc.__onload || this.frm.doc.__onload.can_update_items) {
|
||||||
this.frm.add_custom_button(__("Update Items"), () => {
|
this.frm.add_custom_button(__("Update Items"), () => {
|
||||||
@@ -347,10 +344,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.frm.has_perm("submit")) {
|
if (this.frm.has_perm("submit")) {
|
||||||
if (
|
if (flt(doc.per_billed) < 100 || flt(doc.per_received) < 100) {
|
||||||
flt(doc.per_billed, precision("per_billed")) < 100 ||
|
|
||||||
flt(doc.per_received, precision("per_received")) < 100
|
|
||||||
) {
|
|
||||||
if (doc.status != "On Hold") {
|
if (doc.status != "On Hold") {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Hold"),
|
__("Hold"),
|
||||||
@@ -388,7 +382,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
}
|
}
|
||||||
if (doc.status != "Closed") {
|
if (doc.status != "Closed") {
|
||||||
if (doc.status != "On Hold") {
|
if (doc.status != "On Hold") {
|
||||||
if (flt(doc.per_received, precision("per_received")) < 100 && allow_receipt) {
|
if (flt(doc.per_received) < 100 && allow_receipt) {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Purchase Receipt"),
|
__("Purchase Receipt"),
|
||||||
this.make_purchase_receipt,
|
this.make_purchase_receipt,
|
||||||
@@ -415,14 +409,14 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Please do not add precision in the below flt function
|
// Please do not add precision in the below flt function
|
||||||
if (flt(doc.per_billed, precision("per_billed")) < 100)
|
if (flt(doc.per_billed) < 100)
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Purchase Invoice"),
|
__("Purchase Invoice"),
|
||||||
this.make_purchase_invoice,
|
this.make_purchase_invoice,
|
||||||
__("Create")
|
__("Create")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (flt(doc.per_billed, precision("per_billed")) < 100 && doc.status != "Delivered") {
|
if (flt(doc.per_billed) < 100 && doc.status != "Delivered") {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Payment"),
|
__("Payment"),
|
||||||
() => this.make_payment_entry(),
|
() => this.make_payment_entry(),
|
||||||
@@ -430,7 +424,7 @@ erpnext.buying.PurchaseOrderController = class PurchaseOrderController extends (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flt(doc.per_billed, precision("per_billed")) < 100) {
|
if (flt(doc.per_billed) < 100) {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Payment Request"),
|
__("Payment Request"),
|
||||||
function () {
|
function () {
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ frappe.ui.form.on("Sales Order", {
|
|||||||
if (frm.doc.docstatus === 1) {
|
if (frm.doc.docstatus === 1) {
|
||||||
if (
|
if (
|
||||||
frm.doc.status !== "Closed" &&
|
frm.doc.status !== "Closed" &&
|
||||||
flt(frm.doc.per_delivered, precision("per_delivered")) < 100 &&
|
flt(frm.doc.per_delivered) < 100 &&
|
||||||
flt(frm.doc.per_billed, precision("per_billed")) < 100 &&
|
flt(frm.doc.per_billed) < 100 &&
|
||||||
frm.has_perm("write")
|
frm.has_perm("write")
|
||||||
) {
|
) {
|
||||||
frm.add_custom_button(__("Update Items"), () => {
|
frm.add_custom_button(__("Update Items"), () => {
|
||||||
@@ -61,7 +61,7 @@ frappe.ui.form.on("Sales Order", {
|
|||||||
if (
|
if (
|
||||||
frm.doc.__onload &&
|
frm.doc.__onload &&
|
||||||
frm.doc.__onload.has_unreserved_stock &&
|
frm.doc.__onload.has_unreserved_stock &&
|
||||||
flt(frm.doc.per_picked, precision("per_picked")) === 0
|
flt(frm.doc.per_picked) === 0
|
||||||
) {
|
) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Reserve"),
|
__("Reserve"),
|
||||||
@@ -590,10 +590,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
__("Status")
|
__("Status")
|
||||||
);
|
);
|
||||||
|
|
||||||
if (
|
if (flt(doc.per_delivered) < 100 || flt(doc.per_billed) < 100) {
|
||||||
flt(doc.per_delivered, precision("per_delivered")) < 100 ||
|
|
||||||
flt(doc.per_billed, precision("per_billed")) < 100
|
|
||||||
) {
|
|
||||||
// close
|
// close
|
||||||
this.frm.add_custom_button(__("Close"), () => this.close_sales_order(), __("Status"));
|
this.frm.add_custom_button(__("Close"), () => this.close_sales_order(), __("Status"));
|
||||||
}
|
}
|
||||||
@@ -616,10 +613,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
) && !this.frm.doc.skip_delivery_note;
|
) && !this.frm.doc.skip_delivery_note;
|
||||||
|
|
||||||
if (this.frm.has_perm("submit")) {
|
if (this.frm.has_perm("submit")) {
|
||||||
if (
|
if (flt(doc.per_delivered) < 100 || flt(doc.per_billed) < 100) {
|
||||||
flt(doc.per_delivered, precision("per_delivered")) < 100 ||
|
|
||||||
flt(doc.per_billed, precision("per_billed")) < 100
|
|
||||||
) {
|
|
||||||
// hold
|
// hold
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Hold"),
|
__("Hold"),
|
||||||
@@ -637,8 +631,8 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
(!doc.__onload || !doc.__onload.has_reserved_stock) &&
|
(!doc.__onload || !doc.__onload.has_reserved_stock) &&
|
||||||
flt(doc.per_picked, precision("per_picked")) < 100 &&
|
flt(doc.per_picked) < 100 &&
|
||||||
flt(doc.per_delivered, precision("per_delivered")) < 100 &&
|
flt(doc.per_delivered) < 100 &&
|
||||||
frappe.model.can_create("Pick List")
|
frappe.model.can_create("Pick List")
|
||||||
) {
|
) {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
@@ -656,7 +650,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
|
|
||||||
// delivery note
|
// delivery note
|
||||||
if (
|
if (
|
||||||
flt(doc.per_delivered, precision("per_delivered")) < 100 &&
|
flt(doc.per_delivered) < 100 &&
|
||||||
(order_is_a_sale || order_is_a_custom_sale) &&
|
(order_is_a_sale || order_is_a_custom_sale) &&
|
||||||
allow_delivery
|
allow_delivery
|
||||||
) {
|
) {
|
||||||
@@ -678,10 +672,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sales invoice
|
// sales invoice
|
||||||
if (
|
if (flt(doc.per_billed) < 100 && frappe.model.can_create("Sales Invoice")) {
|
||||||
flt(doc.per_billed, precision("per_billed")) < 100 &&
|
|
||||||
frappe.model.can_create("Sales Invoice")
|
|
||||||
) {
|
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Sales Invoice"),
|
__("Sales Invoice"),
|
||||||
() => me.make_sales_invoice(),
|
() => me.make_sales_invoice(),
|
||||||
@@ -692,8 +683,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
// material request
|
// material request
|
||||||
if (
|
if (
|
||||||
(!doc.order_type ||
|
(!doc.order_type ||
|
||||||
((order_is_a_sale || order_is_a_custom_sale) &&
|
((order_is_a_sale || order_is_a_custom_sale) && flt(doc.per_delivered) < 100)) &&
|
||||||
flt(doc.per_delivered, precision("per_delivered")) < 100)) &&
|
|
||||||
frappe.model.can_create("Material Request")
|
frappe.model.can_create("Material Request")
|
||||||
) {
|
) {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
@@ -718,10 +708,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// maintenance
|
// maintenance
|
||||||
if (
|
if (flt(doc.per_delivered) < 100 && (order_is_maintenance || order_is_a_custom_sale)) {
|
||||||
flt(doc.per_delivered, precision("per_delivered")) < 100 &&
|
|
||||||
(order_is_maintenance || order_is_a_custom_sale)
|
|
||||||
) {
|
|
||||||
if (frappe.model.can_create("Maintenance Visit")) {
|
if (frappe.model.can_create("Maintenance Visit")) {
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Maintenance Visit"),
|
__("Maintenance Visit"),
|
||||||
@@ -739,10 +726,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
}
|
}
|
||||||
|
|
||||||
// project
|
// project
|
||||||
if (
|
if (flt(doc.per_delivered) < 100 && frappe.model.can_create("Project")) {
|
||||||
flt(doc.per_delivered, precision("per_delivered")) < 100 &&
|
|
||||||
frappe.model.can_create("Project")
|
|
||||||
) {
|
|
||||||
this.frm.add_custom_button(__("Project"), () => this.make_project(), __("Create"));
|
this.frm.add_custom_button(__("Project"), () => this.make_project(), __("Create"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,10 +754,7 @@ erpnext.selling.SalesOrderController = class SalesOrderController extends erpnex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// payment request
|
// payment request
|
||||||
if (
|
if (flt(doc.per_billed) < 100 + frappe.boot.sysdefaults.over_billing_allowance) {
|
||||||
flt(doc.per_billed, precision("per_billed", doc)) <
|
|
||||||
100 + frappe.boot.sysdefaults.over_billing_allowance
|
|
||||||
) {
|
|
||||||
this.frm.add_custom_button(
|
this.frm.add_custom_button(
|
||||||
__("Payment Request"),
|
__("Payment Request"),
|
||||||
() => this.make_payment_request(),
|
() => this.make_payment_request(),
|
||||||
|
|||||||
@@ -20,14 +20,20 @@ frappe.listview_settings["Sales Order"] = {
|
|||||||
return [__("On Hold"), "orange", "status,=,On Hold"];
|
return [__("On Hold"), "orange", "status,=,On Hold"];
|
||||||
} else if (doc.status === "Completed") {
|
} else if (doc.status === "Completed") {
|
||||||
return [__("Completed"), "green", "status,=,Completed"];
|
return [__("Completed"), "green", "status,=,Completed"];
|
||||||
|
<<<<<<< HEAD
|
||||||
} else if (!doc.skip_delivery_note && flt(doc.per_delivered, 2) < 100) {
|
} else if (!doc.skip_delivery_note && flt(doc.per_delivered, 2) < 100) {
|
||||||
|
=======
|
||||||
|
} else if (doc.advance_payment_status === "Requested") {
|
||||||
|
return [__("To Pay"), "gray", "advance_payment_status,=,Requested"];
|
||||||
|
} else if (!doc.skip_delivery_note && flt(doc.per_delivered) < 100) {
|
||||||
|
>>>>>>> eff9cd10cd (fix: remove field precision in SO and PO for percentage fields)
|
||||||
if (frappe.datetime.get_diff(doc.delivery_date) < 0) {
|
if (frappe.datetime.get_diff(doc.delivery_date) < 0) {
|
||||||
// not delivered & overdue
|
// not delivered & overdue
|
||||||
return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Closed"];
|
return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Closed"];
|
||||||
} else if (flt(doc.grand_total) === 0) {
|
} else if (flt(doc.grand_total) === 0) {
|
||||||
// not delivered (zeroount order)
|
// not delivered (zeroount order)
|
||||||
return [__("To Deliver"), "orange", "per_delivered,<,100|grand_total,=,0|status,!=,Closed"];
|
return [__("To Deliver"), "orange", "per_delivered,<,100|grand_total,=,0|status,!=,Closed"];
|
||||||
} else if (flt(doc.per_billed, 2) < 100) {
|
} else if (flt(doc.per_billed) < 100) {
|
||||||
// not delivered & not billed
|
// not delivered & not billed
|
||||||
return [
|
return [
|
||||||
__("To Deliver and Bill"),
|
__("To Deliver and Bill"),
|
||||||
@@ -39,13 +45,13 @@ frappe.listview_settings["Sales Order"] = {
|
|||||||
return [__("To Deliver"), "orange", "per_delivered,<,100|per_billed,=,100|status,!=,Closed"];
|
return [__("To Deliver"), "orange", "per_delivered,<,100|per_billed,=,100|status,!=,Closed"];
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
flt(doc.per_delivered, 2) === 100 &&
|
flt(doc.per_delivered) === 100 &&
|
||||||
flt(doc.grand_total) !== 0 &&
|
flt(doc.grand_total) !== 0 &&
|
||||||
flt(doc.per_billed, 2) < 100
|
flt(doc.per_billed) < 100
|
||||||
) {
|
) {
|
||||||
// to bill
|
// to bill
|
||||||
return [__("To Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Closed"];
|
return [__("To Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Closed"];
|
||||||
} else if (doc.skip_delivery_note && flt(doc.per_billed, 2) < 100) {
|
} else if (doc.skip_delivery_note && flt(doc.per_billed) < 100) {
|
||||||
return [__("To Bill"), "orange", "per_billed,<,100|status,!=,Closed"];
|
return [__("To Bill"), "orange", "per_billed,<,100|status,!=,Closed"];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user