salary slip calculation: trigger on
This commit is contained in:
parent
c7aba3331b
commit
786472279a
@ -51,8 +51,10 @@ cur_frm.cscript.e_modified_amount = function(doc,dt,dn){
|
||||
calculate_net_pay(doc, dt, dn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.e_depends_on_lwp = cur_frm.cscript.e_modified_amount;
|
||||
|
||||
cur_frm.cscript.e_depends_on_lwp = function(doc,dt,dn){
|
||||
calculate_earning_total(doc, dt, dn, true);
|
||||
calculate_net_pay(doc, dt, dn);
|
||||
}
|
||||
// Trigger on earning modified amount and depends on lwp
|
||||
// ------------------------------------------------------------------------
|
||||
cur_frm.cscript.d_modified_amount = function(doc,dt,dn){
|
||||
@ -60,17 +62,24 @@ cur_frm.cscript.d_modified_amount = function(doc,dt,dn){
|
||||
calculate_net_pay(doc, dt, dn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.d_depends_on_lwp = cur_frm.cscript.d_modified_amount;
|
||||
cur_frm.cscript.d_depends_on_lwp = function(doc, dt, dn) {
|
||||
calculate_ded_total(doc, dt, dn, true);
|
||||
calculate_net_pay(doc, dt, dn);
|
||||
};
|
||||
|
||||
// Calculate earning total
|
||||
// ------------------------------------------------------------------------
|
||||
var calculate_earning_total = function(doc, dt, dn) {
|
||||
var calculate_earning_total = function(doc, dt, dn, reset_amount) {
|
||||
var tbl = doc.earnings || [];
|
||||
|
||||
var total_earn = 0;
|
||||
for(var i = 0; i < tbl.length; i++){
|
||||
if(cint(tbl[i].e_depends_on_lwp) == 1) {
|
||||
tbl[i].e_modified_amount = Math.round(tbl[i].e_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)*100)/100;
|
||||
tbl[i].e_modified_amount = Math.round(tbl[i].e_amount)*(flt(doc.payment_days) /
|
||||
cint(doc.total_days_in_month)*100)/100;
|
||||
refresh_field('e_modified_amount', tbl[i].name, 'earnings');
|
||||
} else if(reset_amount) {
|
||||
tbl[i].e_modified_amount = tbl[i].e_amount;
|
||||
refresh_field('e_modified_amount', tbl[i].name, 'earnings');
|
||||
}
|
||||
total_earn += flt(tbl[i].e_modified_amount);
|
||||
@ -81,7 +90,7 @@ var calculate_earning_total = function(doc, dt, dn) {
|
||||
|
||||
// Calculate deduction total
|
||||
// ------------------------------------------------------------------------
|
||||
var calculate_ded_total = function(doc, dt, dn) {
|
||||
var calculate_ded_total = function(doc, dt, dn, reset_amount) {
|
||||
var tbl = doc.deductions || [];
|
||||
|
||||
var total_ded = 0;
|
||||
@ -89,6 +98,9 @@ var calculate_ded_total = function(doc, dt, dn) {
|
||||
if(cint(tbl[i].d_depends_on_lwp) == 1) {
|
||||
tbl[i].d_modified_amount = Math.round(tbl[i].d_amount)*(flt(doc.payment_days)/cint(doc.total_days_in_month)*100)/100;
|
||||
refresh_field('d_modified_amount', tbl[i].name, 'deductions');
|
||||
} else if(reset_amount) {
|
||||
tbl[i].d_modified_amount = tbl[i].d_amount;
|
||||
refresh_field('d_modified_amount', tbl[i].name, 'earnings');
|
||||
}
|
||||
total_ded += flt(tbl[i].d_modified_amount);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
{
|
||||
"fieldname": "d_amount",
|
||||
"fieldtype": "Currency",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Default Amount",
|
||||
"oldfieldname": "d_amount",
|
||||
"oldfieldtype": "Currency",
|
||||
@ -27,6 +27,14 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "d_depends_on_lwp",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 0,
|
||||
"label": "Depends on LWP",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "d_modified_amount",
|
||||
"fieldtype": "Currency",
|
||||
@ -34,19 +42,11 @@
|
||||
"label": "Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "d_depends_on_lwp",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Depends on LWP",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2014-07-21 07:38:36.059879",
|
||||
"modified": "2015-03-03 12:41:04.505378",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Salary Slip Deduction",
|
||||
|
@ -12,13 +12,13 @@
|
||||
"oldfieldtype": "Data",
|
||||
"options": "Earning Type",
|
||||
"permlevel": 0,
|
||||
"print_width": "200px",
|
||||
"width": "200px"
|
||||
"print_width": "",
|
||||
"width": "80px"
|
||||
},
|
||||
{
|
||||
"fieldname": "e_amount",
|
||||
"fieldtype": "Currency",
|
||||
"in_list_view": 1,
|
||||
"in_list_view": 0,
|
||||
"label": "Default Amount",
|
||||
"oldfieldname": "e_amount",
|
||||
"oldfieldtype": "Currency",
|
||||
@ -27,6 +27,14 @@
|
||||
"print_hide": 1,
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "e_depends_on_lwp",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 0,
|
||||
"label": "Depends on LWP",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "e_modified_amount",
|
||||
"fieldtype": "Currency",
|
||||
@ -34,19 +42,11 @@
|
||||
"label": "Amount",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "e_depends_on_lwp",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Depends on LWP",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"modified": "2014-07-21 07:39:01.262050",
|
||||
"modified": "2015-03-03 12:42:49.087748",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Salary Slip Earning",
|
||||
|
Loading…
x
Reference in New Issue
Block a user