Merge branch 'develop' of https://github.com/frappe/erpnext into Year-to-Date
diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.js b/erpnext/payroll/doctype/salary_slip/salary_slip.js
index f7e22c6..5694871 100644
--- a/erpnext/payroll/doctype/salary_slip/salary_slip.js
+++ b/erpnext/payroll/doctype/salary_slip/salary_slip.js
@@ -125,15 +125,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_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_to_date"],
company_currency);
- frm.set_currency_labels(["hour_rate", "gross_pay", "total_deduction", "net_pay", "rounded_total", "total_in_words"],
+ frm.set_currency_labels(["hour_rate", "gross_pay", "total_deduction", "net_pay", "rounded_total", "total_in_words", "year_to_date", "month_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_net_pay", "base_rounded_total", "base_total_in_words", "base_year_to_date", "base_month_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 386618c..43deee4 100644
--- a/erpnext/payroll/doctype/salary_slip/salary_slip.json
+++ b/erpnext/payroll/doctype/salary_slip/salary_slip.json
@@ -69,9 +69,13 @@
"net_pay_info",
"net_pay",
"base_net_pay",
+ "year_to_date",
+ "base_year_to_date",
"column_break_53",
"rounded_total",
"base_rounded_total",
+ "month_to_date",
+ "base_month_to_date",
"section_break_55",
"total_in_words",
"column_break_69",
@@ -578,13 +582,41 @@
{
"fieldname": "column_break_69",
"fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "year_to_date",
+ "fieldtype": "Currency",
+ "label": "Year To Date",
+ "options": "currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "month_to_date",
+ "fieldtype": "Currency",
+ "label": "Month To Date",
+ "options": "currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_year_to_date",
+ "fieldtype": "Currency",
+ "label": "Year To Date(Company Currency)",
+ "options": "Company:company:default_currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_month_to_date",
+ "fieldtype": "Currency",
+ "label": "Month To Date(Company Currency)",
+ "options": "Company:company:default_currency",
+ "read_only": 1
}
],
"icon": "fa fa-file-text",
"idx": 9,
"is_submittable": 1,
"links": [],
- "modified": "2020-10-21 23:02:59.400249",
+ "modified": "2020-12-21 23:43:44.959840",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Salary Slip",
diff --git a/erpnext/payroll/doctype/salary_slip/salary_slip.py b/erpnext/payroll/doctype/salary_slip/salary_slip.py
index 20365b1..02e5f2d 100644
--- a/erpnext/payroll/doctype/salary_slip/salary_slip.py
+++ b/erpnext/payroll/doctype/salary_slip/salary_slip.py
@@ -5,7 +5,7 @@
import frappe, erpnext
import datetime, math
-from frappe.utils import add_days, cint, cstr, flt, getdate, rounded, date_diff, money_in_words, formatdate
+from frappe.utils import add_days, cint, cstr, flt, getdate, rounded, date_diff, money_in_words, formatdate, get_first_day
from frappe.model.naming import make_autoname
from frappe import msgprint, _
@@ -49,6 +49,8 @@
self.get_working_days_details(lwp = self.leave_without_pay)
self.calculate_net_pay()
+ self.compute_year_to_date()
+ self.compute_month_to_date()
if frappe.db.get_single_value("Payroll Settings", "max_working_hours_against_timesheet"):
max_working_hours = frappe.db.get_single_value("Payroll Settings", "max_working_hours_against_timesheet")
@@ -1125,6 +1127,42 @@
self.gross_pay += self.earnings[i].amount
self.net_pay = flt(self.gross_pay) - flt(self.total_deduction)
+ def compute_year_to_date(self):
+ year_to_date = 0
+ payroll_period = frappe.get_list('Payroll Period',
+ fields = ['start_date','end_date','company'],
+ filters= {'start_date' : ['<=', self.start_date],
+ 'end_date' : ['>=', self.end_date],
+ 'company' : self.company
+ })[0]
+ salary_slips_from_current_payroll_period = frappe.get_list('Salary Slip',
+ fields = ['employee_name', 'start_date', 'end_date', 'net_pay'],
+ filters = {'employee_name' : self.employee_name,
+ 'start_date' : ['>=', payroll_period.start_date],
+ 'end_date' : ['<', self.start_date]
+ })
+
+ for salary_slip in salary_slips_from_current_payroll_period:
+ year_to_date += salary_slip.net_pay
+
+ year_to_date += self.net_pay
+ self.year_to_date = year_to_date
+
+ def compute_month_to_date(self):
+ month_to_date = 0
+ first_day_of_the_month = get_first_day(self.start_date)
+ salary_slips_from_this_month = frappe.get_list('Salary Slip',
+ fields = ['employee_name', 'start_date', 'net_pay'],
+ filters = {'employee_name' : self.employee_name,
+ 'start_date' : ['>=', first_day_of_the_month],
+ 'end_date' : ['<', self.start_date]
+ })
+ for salary_slip in salary_slips_from_this_month:
+ month_to_date += salary_slip.net_pay
+
+ month_to_date += self.net_pay
+ self.month_to_date = month_to_date
+
def unlink_ref_doc_from_salary_slip(ref_no):
linked_ss = frappe.db.sql_list("""select name from `tabSalary Slip`
where journal_entry=%s and docstatus < 2""", (ref_no))
@@ -1135,4 +1173,4 @@
def generate_password_for_pdf(policy_template, employee):
employee = frappe.get_doc("Employee", employee)
- return policy_template.format(**employee.as_dict())
+ return policy_template.format(**employee.as_dict())
\ No newline at end of file