diff --git a/addons/l10n_in_hr_payroll/__openerp__.py b/addons/l10n_in_hr_payroll/__openerp__.py index 1eca0d3ceba..199dc0a232c 100644 --- a/addons/l10n_in_hr_payroll/__openerp__.py +++ b/addons/l10n_in_hr_payroll/__openerp__.py @@ -51,6 +51,7 @@ Indian Payroll Salary Rules. 'l10n_in_hr_payroll_report.xml', 'l10n_in_hr_payroll_sequence.xml', 'wizard/hr_salary_employee_bymonth_view.xml', + 'wizard/hr_yearly_salary_detail_view.xml', 'report/payment_advice_report_view.xml', ], diff --git a/addons/l10n_in_hr_payroll/l10n_in_hr_payroll_report.xml b/addons/l10n_in_hr_payroll/l10n_in_hr_payroll_report.xml index 7604f34e32e..4a0c9ded0b9 100644 --- a/addons/l10n_in_hr_payroll/l10n_in_hr_payroll_report.xml +++ b/addons/l10n_in_hr_payroll/l10n_in_hr_payroll_report.xml @@ -25,5 +25,14 @@ name="salary.employee.bymonth" rml="l10n_in_hr_payroll/report/report_hr_salary_employee_bymonth.rml" string="Payroll Statement" /> + + + diff --git a/addons/l10n_in_hr_payroll/report/__init__.py b/addons/l10n_in_hr_payroll/report/__init__.py index 3091692c2e8..5c76aa37e1c 100644 --- a/addons/l10n_in_hr_payroll/report/__init__.py +++ b/addons/l10n_in_hr_payroll/report/__init__.py @@ -26,5 +26,6 @@ import report_payslip_details import report_payroll_advice import report_hr_salary_employee_bymonth import payment_advice_report +import report_hr_yearly_salary_detail # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_in_hr_payroll/report/report_hr_yearly_salary_detail.py b/addons/l10n_in_hr_payroll/report/report_hr_yearly_salary_detail.py new file mode 100644 index 00000000000..576fd302f6f --- /dev/null +++ b/addons/l10n_in_hr_payroll/report/report_hr_yearly_salary_detail.py @@ -0,0 +1,164 @@ +#-*- coding:utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 OpenERP SA (). All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +import datetime +from report import report_sxw + +class employees_yearly_salary_report(report_sxw.rml_parse): + + def __init__(self, cr, uid, name, context): + super(employees_yearly_salary_report, self).__init__(cr, uid, name, context) + + self.localcontext.update({ + 'time': time, + 'get_employee': self.get_employee, + 'get_employee_detail': self.get_employee_detail, + 'cal_monthly_amt': self.cal_monthly_amt, + 'get_periods': self.get_periods, + 'get_total': self.get_total, + 'get_allow': self.get_allow, + 'get_deduct': self.get_deduct, + }) + + self.context = context + + def get_periods(self, form): + self.mnths = [] +# Get start year-month-date and end year-month-date + first_year = int(form['date_from'][0:4]) + last_year = int(form['date_to'][0:4]) + + first_month = int(form['date_from'][5:7]) + last_month = int(form['date_to'][5:7]) + no_months = (last_year-first_year) * 12 + last_month - first_month + 1 + current_month = first_month + current_year = first_year + +# Get name of the months from integer + mnth_name = [] + for count in range(0, no_months): + m = datetime.date(current_year, current_month, 1).strftime('%b') + mnth_name.append(m) + self.mnths.append(str(current_month) + '-' + str(current_year)) + if current_month == 12: + current_month = 0 + current_year = last_year + current_month = current_month + 1 + for c in range(0, (12-no_months)): + mnth_name.append('None') + self.mnths.append('None') + return [mnth_name] + + def get_employee(self, form): + return self.pool.get('hr.employee').browse(self.cr,self.uid, form.get('employee_ids', []), context=self.context) + + def get_employee_detail(self, form, obj): + self.allow_list = [] + self.deduct_list = [] + self.total = 0.00 + gross = False + net = False + + payslip_lines = self.cal_monthly_amt(form, obj.id) + for line in payslip_lines: + for line[0] in line: + if line[0][0] == "Gross": + gross = line[0] + elif line[0][0] == "Net": + net = line[0] + elif line[0][13] > 0.0 and line[0][0] != "Net": + self.total += line[0][len(line[0])-1] + self.allow_list.append(line[0]) + elif line[0][13] < 0.0: + self.total += line[0][len(line[0])-1] + self.deduct_list.append(line[0]) + if gross: + self.allow_list.append(gross) + if net: + self.deduct_list.append(net) + return None + + def cal_monthly_amt(self, form, emp_id): + category_obj = self.pool.get('hr.salary.rule.category') + result = [] + res = [] + salaries = {} + self.cr.execute('''SELECT rc.code, pl.name, sum(pl.total), \ + to_char(date_to,'mm-yyyy') as to_date FROM hr_payslip_line as pl \ + LEFT JOIN hr_salary_rule_category AS rc on (pl.category_id = rc.id) \ + LEFT JOIN hr_payslip as p on pl.slip_id = p.id \ + LEFT JOIN hr_employee as emp on emp.id = p.employee_id \ + WHERE p.employee_id = %s \ + GROUP BY rc.parent_id, pl.sequence, pl.id, pl.category_id,pl.name,p.date_to,rc.code \ + ORDER BY pl.sequence, rc.parent_id''',(emp_id,)) + salary = self.cr.fetchall() + for category in salary: + if category[0] not in salaries: + salaries.setdefault(category[0], {}) + salaries[category[0]].update({category[1]: {category[3]: category[2]}}) + elif category[1] not in salaries[category[0]]: + salaries[category[0]].setdefault(category[1], {}) + salaries[category[0]][category[1]].update({category[3]: category[2]}) + else: + salaries[category[0]][category[1]].update({category[3]: category[2]}) + + category_ids = category_obj.search(self.cr,self.uid, [], context=self.context) + categories = category_obj.read(self.cr, self.uid, category_ids, ['code'], context=self.context) + for code in map(lambda x: x['code'], categories): + if code in salaries: + res = self.salary_list(salaries[code]) + result.append(res) + return result + + def salary_list(self, salaries): + cat_salary_all = [] + for category_name,amount in salaries.items(): + cat_salary = [] + total = 0.0 + cat_salary.append(category_name) + for mnth in self.mnths: + if mnth <> 'None': + if len(mnth) != 7: + mnth = '0' + str(mnth) + if mnth in amount and amount[mnth]: + cat_salary.append(amount[mnth]) + total += amount[mnth] + else: + cat_salary.append(0.00) + else: + cat_salary.append('') + cat_salary.append(total) + cat_salary_all.append(cat_salary) + return cat_salary_all + + def get_allow(self): + return self.allow_list + + def get_deduct(self): + return self.deduct_list + + def get_total(self): + return self.total + +report_sxw.report_sxw('report.salary.detail.byyear', 'yearly.salary.detail', 'hr_payroll/report/report_hr_yearly_salary_detail.rml', parser=employees_yearly_salary_report, header='internal landscape') + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/l10n_in_hr_payroll/report/report_hr_yearly_salary_detail.rml b/addons/l10n_in_hr_payroll/report/report_hr_yearly_salary_detail.rml new file mode 100644 index 00000000000..3a9412d7008 --- /dev/null +++ b/addons/l10n_in_hr_payroll/report/report_hr_yearly_salary_detail.rml @@ -0,0 +1,564 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ repeatIn(get_employee(data['form']), 'o') ]] + + + + Employees Salary Details + From [[ formatLang(data['form']['date_from'], date=True) ]] To [[ formatLang(data['form']['date_to'], date=True) ]] + + + + + + + + + + Employee Code + + + [[ o.ssnid ]] + + + Department + + + [[ o.company_id and o.company_id.name or '' ]] + + + Bank + + + [[ o.otherid or '' ]] + + + + + + + Employee Name + + + [[ o.name ]] + + + Other No. + + + [[ o.otherid or '' ]] + + + Address + + + [[o.address_home_id and o.address_home_id.name or '' ]] + + + + + + + Designation + + + [[ o.contract_ids and o.contract_ids[0].job_id.name or '' ]] + + + Phone No. + + + [[ o.work_phone or '' ]] + + + E-mail Address + + + [[o.work_email or '' ]] + + + + + + +
+ [[ repeatIn(get_periods(data['form']),'m') ]] + [[ get_employee_detail((data['form']),o) ]] + + + + Title + + + [[ m[0] != 'None' and m[0] or '' ]] + + + [[ m[1] != 'None' and m[1] or '' ]] + + + [[ m[2] != 'None' and m[2] or '' ]] + + + [[ m[3] != 'None' and m[3] or '' ]] + + + [[ m[4] != 'None' and m[4] or '' ]] + + + [[ m[5] != 'None' and m[5] or '' ]] + + + [[ m[6] != 'None' and m[6] or '' ]] + + + [[ m[7] != 'None' and m[7] or '' ]] + + + [[ m[8] != 'None' and m[8] or '' ]] + + + [[ m[9] != 'None' and m[9] or '' ]] + + + [[ m[10] != 'None' and m[10] or '' ]] + + + [[ m[11] != 'None' and m[11] or '' ]] + + + Total + + + + + + +
+ + + + Allowances with Basic: + + + +
+ [[ repeatIn(get_allow(),'e1') ]] + + + + [[ e1[0] ]] + + + + [[ (e1[1]!='' and formatLang(e1[1])) or removeParentNode('font') ]] + + + + + [[ (e1[2]!='' and formatLang(e1[2])) or removeParentNode('font') ]] + + + + + [[ (e1[3]!='' and formatLang(e1[3])) or removeParentNode('font') ]] + + + + + [[ (e1[4]!='' and formatLang(e1[4])) or removeParentNode('font') ]] + + + + + [[ (e1[5]!='' and formatLang(e1[5])) or removeParentNode('font') ]] + + + + + [[ (e1[6]!='' and formatLang(e1[6])) or removeParentNode('font') ]] + + + + + [[ (e1[7]!='' and formatLang(e1[7])) or removeParentNode('font') ]] + + + + + [[ (e1[8]!='' and formatLang(e1[8])) or removeParentNode('font') ]] + + + + + [[ (e1[9]!='' and formatLang(e1[9])) or removeParentNode('font') ]] + + + + + [[ (e1[10]!='' and formatLang(e1[10])) or removeParentNode('font') ]] + + + + + [[ (e1[11]!='' and formatLang(e1[11])) or removeParentNode('font') ]] + + + + + [[ (e1[12]!='' and formatLang(e1[12])) or removeParentNode('font') ]] + + + + [[ formatLang(e1[13]) ]] [[ company.currency_id.symbol ]] + + + +
+ + + + Deductions: + + + +
+ [[ repeatIn(get_deduct(),'e2') ]] + + + + [[ e2[0] ]] + + + + [[ (e2[1]!='' and formatLang(e2[1])) or removeParentNode('font') ]] + + + + + [[ (e2[2]!='' and formatLang(e2[2])) or removeParentNode('font') ]] + + + + + [[ (e2[3]!='' and formatLang(e2[3])) or removeParentNode('font') ]] + + + + + [[ (e2[4]!='' and formatLang(e2[4])) or removeParentNode('font') ]] + + + + + [[ (e2[5]!='' and formatLang(e2[5])) or removeParentNode('font') ]] + + + + + [[ (e2[6]!='' and formatLang(e2[6])) or removeParentNode('font') ]] + + + + + [[ (e2[7]!='' and formatLang(e2[7])) or removeParentNode('font') ]] + + + + + [[ (e2[8]!='' and formatLang(e2[8])) or removeParentNode('font') ]] + + + + + [[ (e2[9]!='' and formatLang(e2[9])) or removeParentNode('font') ]] + + + + + [[ (e2[10]!='' and formatLang(e2[10])) or removeParentNode('font') ]] + + + + + [[ (e2[11]!='' and formatLang(e2[11])) or removeParentNode('font') ]] + + + + + [[ (e2[12]!='' and formatLang(e2[12])) or removeParentNode('font') ]] + + + + [[ formatLang(e2[13]) ]] [[ company.currency_id.symbol ]] + + + +
+
+ + + +
+ + + +
+
diff --git a/addons/l10n_in_hr_payroll/wizard/__init__.py b/addons/l10n_in_hr_payroll/wizard/__init__.py index b08ed5a3f9c..36635aec3c2 100644 --- a/addons/l10n_in_hr_payroll/wizard/__init__.py +++ b/addons/l10n_in_hr_payroll/wizard/__init__.py @@ -20,5 +20,6 @@ ############################################################################## import hr_salary_employee_bymonth +import hr_yearly_salary_detail # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py b/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py index 43bfa4da177..f8be2799f35 100644 --- a/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py +++ b/addons/l10n_in_hr_payroll/wizard/hr_salary_employee_bymonth.py @@ -30,7 +30,7 @@ class hr_salary_employee_bymonth(osv.osv_memory): _columns = { 'start_date': fields.date('Start Date', required=True), 'end_date': fields.date('End Date', required=True), - 'employee_ids': fields.many2many('hr.employee', 'payroll_year_rel', 'payroll_year_id', 'emp_id', 'Employees', required=True), + 'employee_ids': fields.many2many('hr.employee', 'payroll_year_rel', 'payroll_year_id', 'employee_id', 'Employees', required=True), } _defaults = { diff --git a/addons/l10n_in_hr_payroll/wizard/hr_yearly_salary_detail.py b/addons/l10n_in_hr_payroll/wizard/hr_yearly_salary_detail.py new file mode 100644 index 00000000000..6efceb875db --- /dev/null +++ b/addons/l10n_in_hr_payroll/wizard/hr_yearly_salary_detail.py @@ -0,0 +1,66 @@ +#-*- coding:utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2011 OpenERP SA (). All Rights Reserved +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time + +from osv import fields, osv + +class yearly_salary_detail(osv.osv_memory): + + _name ='yearly.salary.detail' + _description = 'Hr Salary Employee By Category Report' + _columns = { + 'employee_ids': fields.many2many('hr.employee', 'payroll_emp_rel', 'payroll_id', 'employee_id', 'Employees', required=True), + 'date_from': fields.date('Start Date', required=True), + 'date_to': fields.date('End Date', required=True), + } + + _defaults = { + 'date_from': lambda *a: time.strftime('%Y-01-01'), + 'date_to': lambda *a: time.strftime('%Y-%m-%d'), + + } + + def print_report(self, cr, uid, ids, context=None): + """ + To get the date and print the report + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param context: A standard dictionary + @return: return report + """ + if context is None: + context = {} + datas = {'ids': context.get('active_ids', [])} + + res = self.read(cr, uid, ids, ['employee_ids', 'date_from', 'date_to'], context=context) + res = res and res[0] or {} + datas.update({'form': res}) + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'salary.detail.byyear', + 'datas': datas, + } + +yearly_salary_detail() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/l10n_in_hr_payroll/wizard/hr_yearly_salary_detail_view.xml b/addons/l10n_in_hr_payroll/wizard/hr_yearly_salary_detail_view.xml new file mode 100644 index 00000000000..9540af8b332 --- /dev/null +++ b/addons/l10n_in_hr_payroll/wizard/hr_yearly_salary_detail_view.xml @@ -0,0 +1,43 @@ + + + + + Employee Yearly Salary + yearly.salary.detail + form + +
+
+
+ + + + + + +
+
+
+ + + Payroll Register + ir.actions.act_window + yearly.salary.detail + form + form + new + + + + +
+