mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-07 20:42:50 +00:00
feat: option to recalculate costing and billing fields in project
(cherry picked from commit dd23d4c81b)
This commit is contained in:
@@ -88,9 +88,9 @@ frappe.ui.form.on("Project", {
|
|||||||
);
|
);
|
||||||
|
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Update Total Purchase Cost"),
|
__("Recalculate Costing and Billing"),
|
||||||
() => {
|
() => {
|
||||||
frm.events.update_total_purchase_cost(frm);
|
frm.events.recalculate_costing_and_billing(frm);
|
||||||
},
|
},
|
||||||
__("Actions")
|
__("Actions")
|
||||||
);
|
);
|
||||||
@@ -129,15 +129,15 @@ frappe.ui.form.on("Project", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
update_total_purchase_cost: function (frm) {
|
recalculate_costing_and_billing: function (frm) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "erpnext.projects.doctype.project.project.recalculate_project_total_purchase_cost",
|
method: "erpnext.projects.doctype.project.project.recalculate_costing_and_billing",
|
||||||
args: { project: frm.doc.name },
|
args: { project: frm.doc.name },
|
||||||
freeze: true,
|
freeze: true,
|
||||||
freeze_message: __("Recalculating Purchase Cost against this Project..."),
|
freeze_message: __("Recalculating Costing and Billing fields against this Project..."),
|
||||||
callback: function (r) {
|
callback: function (r) {
|
||||||
if (r && !r.exc) {
|
if (r && !r.exc) {
|
||||||
frappe.msgprint(__("Total Purchase Cost has been updated"));
|
frappe.msgprint(__("Costing and Billing fields has been updated"));
|
||||||
frm.refresh();
|
frm.refresh();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -749,12 +749,7 @@ def calculate_total_purchase_cost(project: str | None = None):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def recalculate_project_total_purchase_cost(project: str | None = None):
|
def recalculate_costing_and_billing(project: str | None = None):
|
||||||
if project:
|
project = frappe.get_doc("Project", project)
|
||||||
total_purchase_cost = calculate_total_purchase_cost(project)
|
project.update_costing()
|
||||||
frappe.db.set_value(
|
project.db_update()
|
||||||
"Project",
|
|
||||||
project,
|
|
||||||
"total_purchase_cost",
|
|
||||||
(total_purchase_cost and total_purchase_cost[0][0] or 0),
|
|
||||||
)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user