fix: (Backport-develop) track salary slip ytd gross salary. (#27242)
* fix: track salary slip ytd gross salary.
* fix: ytd gross salary unique label
* Revert "fix: ytd gross salary unique label"
This reverts commit a68b387ac21e32c250d042caf75ef301b5a49a1a.
* fix: gross ytd salary unique label
diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.js b/erpnext/payroll/doctype/salary_slip/salary_slip.js
index 5258f3a..3ef9762 100644
--- a/erpnext/payroll/doctype/salary_slip/salary_slip.js
+++ b/erpnext/payroll/doctype/salary_slip/salary_slip.js
@@ -135,15 +135,15 @@
change_form_labels: function(frm, company_currency) {
frm.set_currency_labels(["base_hour_rate", "base_gross_pay", "base_total_deduction",
- "base_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_to_date"],
+ "base_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_to_date", "gross_base_year_to_date"],
company_currency);
- frm.set_currency_labels(["hour_rate", "gross_pay", "total_deduction", "net_pay", "rounded_total", "total_in_words", "year_to_date", "month_to_date"],
+ frm.set_currency_labels(["hour_rate", "gross_pay", "total_deduction", "net_pay", "rounded_total", "total_in_words", "year_to_date", "month_to_date", "gross_year_to_date"],
frm.doc.currency);
// toggle fields
frm.toggle_display(["exchange_rate", "base_hour_rate", "base_gross_pay", "base_total_deduction",
- "base_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_to_date"],
+ "base_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_to_date", "base_gross_year_to_date"],
frm.doc.currency != company_currency);
},
diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.json b/erpnext/payroll/doctype/salary_slip/salary_slip.json
index 42a0f29..1974403 100644
--- a/erpnext/payroll/doctype/salary_slip/salary_slip.json
+++ b/erpnext/payroll/doctype/salary_slip/salary_slip.json
@@ -56,6 +56,8 @@
"totals",
"gross_pay",
"base_gross_pay",
+ "gross_year_to_date",
+ "base_gross_year_to_date",
"column_break_25",
"total_deduction",
"base_total_deduction",
@@ -625,13 +627,27 @@
"label": "Leave Details",
"options": "Salary Slip Leave",
"read_only": 1
+ },
+ {
+ "fieldname": "gross_year_to_date",
+ "fieldtype": "Currency",
+ "label": "Gross Year To Date",
+ "options": "currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_gross_year_to_date",
+ "fieldtype": "Currency",
+ "label": "Gross Year To Date(Company Currency)",
+ "options": "Company:company:default_currency",
+ "read_only": 1
}
],
"icon": "fa fa-file-text",
"idx": 9,
"is_submittable": 1,
"links": [],
- "modified": "2021-03-31 22:44:09.772331",
+ "modified": "2021-09-01 10:35:52.374549",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Salary Slip",
@@ -672,4 +688,4 @@
"sort_order": "DESC",
"timeline_field": "employee",
"title_field": "employee_name"
-}
\ No newline at end of file
+}
diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.py b/erpnext/payroll/doctype/salary_slip/salary_slip.py
index 6325351..37a0b60 100644
--- a/erpnext/payroll/doctype/salary_slip/salary_slip.py
+++ b/erpnext/payroll/doctype/salary_slip/salary_slip.py
@@ -1214,7 +1214,7 @@
period_start_date, period_end_date = self.get_year_to_date_period()
salary_slip_sum = frappe.get_list('Salary Slip',
- fields = ['sum(net_pay) as sum'],
+ fields = ['sum(net_pay) as net_sum', 'sum(gross_pay) as gross_sum'],
filters = {'employee_name' : self.employee_name,
'start_date' : ['>=', period_start_date],
'end_date' : ['<', period_end_date],
@@ -1222,10 +1222,13 @@
'docstatus': 1
})
- year_to_date = flt(salary_slip_sum[0].sum) if salary_slip_sum else 0.0
+ year_to_date = flt(salary_slip_sum[0].net_sum) if salary_slip_sum else 0.0
+ gross_year_to_date = flt(salary_slip_sum[0].gross_sum) if salary_slip_sum else 0.0
year_to_date += self.net_pay
+ gross_year_to_date += self.gross_pay
self.year_to_date = year_to_date
+ self.gross_year_to_date = gross_year_to_date
def compute_month_to_date(self):
month_to_date = 0