Custom script for taxable income

Hi Good Day how can i make a custom script for salary slip by creating a field name taxable income that is based only on earnings plus specific deductions like deduction 1 , deduction 2 deduction 3 is this possible? Thanks in advance kindly refer to the image below

1 Like

You can use somthing like this code:

frappe.ui.form.on('Salary Slip', {
    validate: function(frm){

        var total_deduction = 0;
        $.each(frm.doc.deduction || [], function (i, d) {
            if (d.component in ('Deduction1','Deduction2','Deduction3') ) {
                total_deduction += flt(d.amount);
            }
        });

        frm.set_value('taxable_field', frm.gross_pay+total_deduction);

    }
});

Edit field name

Okay Omar… i will try this later and il give ylu a feedback thank you soooool much for guidance and instruction.

Hi Sir do i miss something kindly check the screenshot below i try to create a custom script under salary slip and place your code. But it seems it doesnt work. My field type name under salary slip is taxable_incomes under Float type. Should i change something? Thank you.

child table name is deductions not deduction
component name is salary_component

I write test code, you need to check actual fields name

Okay im going to check it since this is my first time uaing custom script. Thanks again.

Hi yhenn. Did you fixed the problem?