New field for Unbill Amount ( Sales Order Amount - Sales Invoice amount)

Hi All,

I would like to add new field to project module ( in costing and billing section). The purpose of this field is to the get the balance unbill amount from Sales order ( Sales Order amount minus sales invoice amount).

May I know if someone had done the custom script for this.

Thank you

Regards
Charnack

  1. Create a new field via Customize Form. Let’s call it Pending Billable (pending_billable).
  2. Go to client script. Write the following for Project:
frappe.ui.form.on('Project', {
	refresh(frm) {
		let pending = 0
		pending = frm.doc.total_sales_amount - frm.doc.total_billed_amount
		frm.set_value('pending_billable',pending)
	}
})
  1. Enable the script.
  2. Go back to the project and reload. The new field with the value should be populated:

1 Like

Thanks Kenneth,

Its workk…

Regards
Charnack

Hi Kenneth,

The code works well. But I just realize that the number does not appear in List View and Report View.

Any chance that I had set the field wrongly?

Thanks

Working for me:

Can you mark the field as “In List View” via Customize Form and check?

I had add on IN LIST View. Its may take a while maybe. Or else trying to reboot server once again. Thanks Kenneth.

Hi Kenneth,

The code work quite find for total pending billing. But I came across one little issue with the flow.

Field Pending Billing in the project doctype does update according to changes of sales invoice / billing related to that particular project.

Sceario as below

  1. It does not automatically update in list view and report coloum. I need to press save button in order for the value to appear inlist / report view.

  2. Upon submitting the sales invoice, the pending billing figure does not update automatically to pending amount billing. I need to save manually to update the value in project report/list view.

Any idea/ work around i can implement to settle this issue.

Thanks

Regards
Charnack