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