JS code not working

Hello,

I created a Python file that contains the code, then I creates a JS file that contains the code bellow which call the py file, but it doesn’t works, I make. Could you help me please to solve it. Thanks

1- bench --site [site name] migrate
2- bench --site site name] clear-cache
3- service supervisor restart
4-service nginx restart

The new field “custom_big_total_outstanding_amount” which exists in Customer doctype will be updated each time the sales order is saved

The js Code :

frappe.ui.form.on(“Sales Order”, {
before_save: function(frm) {
// Trigger the function after a new Sales Order is inserted
fetchBigTotalOutstandingAmount(frm.doc.customer);

function fetchBigTotalOutstandingAmount(customer) {
// Call the Python function via API
frappe.call({
method: “greenglow_dev.greenglow_development.big_total_outstanding_amount.get_big_total_outstanding_amount”,
args: {
customer: customer
},
callback: function(response) {
// Update the Customer document with the total outstanding amount
frappe.model.set_value(“Customer”, customer, “custom_big_total_outstanding_amount”, response.message)
frm.refresh_field(“custom_big_total_outstanding_amount”);
}
});
}
}
});

can you post “get_big_total_outstanding_amount” function code

is made in py file named “big_total_outstanding_amount”

import frappe

@frappe.whitelist()
def get_big_total_outstanding_amount(customer):
big_total_outstanding_amount = 0

# Fetch sales orders and unpaid invoices for the customer
sales_orders_to_bill = frappe.get_all("Sales Order", filters={"customer": customer, "status": "To Bill"})
sales_orders_to_bill_and_deliver = frappe.get_all("Sales Order", filters={"customer": customer, "status": "To Deliver and Bill"})
unpaid_invoices = frappe.get_all("Sales Invoice", filters={"customer": customer, "status": "Unpaid"})

# Calculate the total outstanding amount
for order in sales_orders_to_bill:
    big_total_outstanding_amount += order.grand_total

for order in sales_orders_to_bill_and_deliver:
    big_total_outstanding_amount += order.grand_total

for invoice in unpaid_invoices:
    total_outstanding_amount += invoice.outstanding_amount

return big_total_outstanding_amount