How to change total amount calculations

in which file can I edit total amount calculation process in sales invoice so I can add another fields to be added in total?

since its a standard doctype, you cannot simply alter the calculation process,

you’ll have to rely on custom script to acheive this

so how to that ? could you help?

@Zeinab_Mohammed

I think it’s easier to assist if you can clearly outline the use case .

I’ve done what you are trying to accomplish by creating custom fields (q1, q2, q3) for managing the qty and (r1,r2) for the rate. Custom scripts can then be used to come up with the actual calculations that then provide input to qty and rate fields.

Neerajvkn is 100% correct and his comment spared you going down the wrong path.
Do not overwrite the standard calculations.

The idea behind the custom fields and scripts is to work around the standard functionality. This makes sure that the system can be upgraded.

When you are done with the custom scripts, you’ll then need to create custom print templates to display the values that suit your usecase.

Good luck!

Excellent ,till now i understood that i need to create new custom script and that done within
settings>new custom script… Right?

so i need each item “amount” underlined with red= multiplication of those three yellow underlined fields could you help me please???
@Eli & @neerajvkn

@Zeinab_Mohammed

The amount value is ALWAYS qty * rate.

You will have to work around this ‘rule’ and that means tweaking your requirement .

please provide little more details, so that we can understand what you want to do, i cannot read arabic(it is i think), so

post your formula with which you want to calcualate

amount = rate * qty * نسبة انجاز الاعمال
this is custom field i created in arabic “نسبة انجاز الاعمال”
or to be clear
amount = rate * qty * my_custom_field
@neerajvkn @Eli

it will be much easier to calculate the rate = actual_rate * custom_field and then letting the system calculate the rest normally

frappe.ui.form.on('Sales Invoice Item',   (frm, cdt, cdn)=> {

var d = locals[cdt][cdn];
frappe.model.set_value("amount",  d.نسبة_انجاز_الاعمال*d.rate*d.qty)   ;

});

i tried that but nothing changed