← Back to team overview

clearcorp team mailing list archive

[Merge] lp:~dr.clearcorp/openerp-ccorp-addons/6.1-hr_payroll_report into lp:openerp-ccorp-addons

 

Diana Rodríguez Martínez has proposed merging lp:~dr.clearcorp/openerp-ccorp-addons/6.1-hr_payroll_report into lp:openerp-ccorp-addons.

Requested reviews:
  CLEARCORP drivers (clearcorp-drivers)

For more details, see:
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-hr_payroll_report/+merge/133300

[ADD] Add a payslip detail report 

-- 
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/6.1-hr_payroll_report/+merge/133300
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== modified file 'hr_payroll_report/hr_payroll_report_report.xml'
--- hr_payroll_report/hr_payroll_report_report.xml	2012-11-07 15:17:20 +0000
+++ hr_payroll_report/hr_payroll_report_report.xml	2012-11-07 17:23:39 +0000
@@ -24,7 +24,16 @@
                     </page>
                 </data>
             </field>
-        </record>       
+        </record>  
+        
+        <report auto="False"
+        id="hr_payroll.payslip_details_report"
+        model="hr.payslip"
+        name="hr_payroll_payslip_details_inherit"
+        file="hr_payroll_report/report/hr_payroll_details_report.mako"
+        string="PaySlip Details"
+        report_type="webkit" />
+             
     </data>
 </openerp>
 

=== modified file 'hr_payroll_report/report/__init__.py'
--- hr_payroll_report/report/__init__.py	2012-10-26 21:07:11 +0000
+++ hr_payroll_report/report/__init__.py	2012-11-07 17:23:39 +0000
@@ -21,5 +21,6 @@
 ##############################################################################
 
 import hr_payroll_report
+import hr_payroll_details_report
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== added file 'hr_payroll_report/report/hr_payroll_details_report.mako'
--- hr_payroll_report/report/hr_payroll_details_report.mako	1970-01-01 00:00:00 +0000
+++ hr_payroll_report/report/hr_payroll_details_report.mako	2012-11-07 17:23:39 +0000
@@ -0,0 +1,155 @@
+<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+    <head>
+        <style type="text/css">
+            .account_level_1 {
+                text-transform: uppercase;
+                font-size: 15px;
+                background-color:#F0F0F0;
+            }
+
+            .account_level_2 {
+                font-size: 12px;
+                background-color:#F0F0F0;
+            }
+
+            .regular_account_type {
+                font-weight: normal;
+            }
+
+            .view_account_type {
+                font-weight: bold;
+            }
+
+            .account_level_consol {
+                font-weight: normal;
+                font-style: italic;
+            }
+
+            ${css}
+
+            .list_table .act_as_row {
+                margin-top: 10px;
+                margin-bottom: 10px;
+                font-size:10px;
+            }
+        </style>
+    </head>
+    <body class = "data">
+        %for payslip in objects :
+        <div style="font-size: 20px; font-weight: bold; text-align: center;"> ${company.partner_id.name | entity} - ${company.currency_id.name | entity}</div>
+        <div style="font-size: 25px; font-weight: bold; text-align: center;"> Comprobante de Pago de Salario</div>
+        <%setLang(user.context_lang)%>        
+        <div style="font-size: 20px; font-weight: bold; text-align: center;"> ${payslip.name or payslip.employee_id.name}</div>
+        <br></br>        
+        <div class="act_as_table data_table" style="width: 500px;">
+            <div class="act_as_thead">
+                <div class="act_as_row lines">
+                    <div class="act_as_cell" style="text-align:left;"><b>${_('Name')}</b></div>
+                    <div class="act_as_cell" style="text-align:left;">${payslip.employee_id.name or '-'}</div>
+               </div>
+               <div class="act_as_row lines">
+                    <div class="act_as_cell"style="text-align:left;"><b>${_('ID card')}</b></div>
+                    <div class="act_as_cell"style="text-align:left;">${payslip.employee_id.ssnid or '-'}</div>  
+               </div>    
+               <div class="act_as_row lines">
+                    <div class="act_as_cell"style="text-align:left;"><b>${_('Bank account')}</b></div>
+                    <div class="act_as_cell"style="text-align:left;">${payslip.employee_id.bank_account_id.name or '-'}</div> 
+               </div>     
+               <div class="act_as_row lines">
+                    <div class="act_as_cell"style="text-align:left;"><b>${_('Job')}</b></div>
+                    <div class="act_as_cell"style="text-align:left;">${payslip.contract_id.job_id.name or '-'}</div>
+               </div>                       
+               <div class="act_as_row lines">  
+                    <div class="act_as_cell"style="text-align:left;"><b>${_('Reference')}</b></div>
+                    <div class="act_as_cell"style="text-align:left;">${payslip.number or '-'}</div>
+               </div>   
+               <div class="act_as_row lines">   
+                    <div class="act_as_cell"style="text-align:left;"><b>${_('Date from')}</b></div>  
+                    <div class="act_as_cell"style="text-align:left;">${payslip.date_from or '-'}</div>
+               </div>    
+               <div class="act_as_row lines">
+                    <div class="act_as_cell"style="text-align:left;"><b>${_('Date to')}</b></div>
+                    <div class="act_as_cell"style="text-align:left;">${payslip.date_to or '-'}</div>
+               </div>     
+               <div class="act_as_row lines">    
+                    <div class="act_as_cell"style="text-align:left;"><b>${_('Salary structure')}</b></div>
+                    <div class="act_as_cell"style="text-align:left;">${payslip.struct_id.name or '-'}</div>
+                </div>
+            </div>   
+        </div>        
+        <br></br><br></br>
+        ##Worked days
+        <% worked_lines_ids = get_worked_lines(cr,uid,payslip.id,payslip.contract_id.schedule_pay) %>
+        <div style="font-size: 16px; font-weight: bold; text-align: left;"> ${_('Quantity of hours')} </div>
+        <div class="act_as_table list_table">
+            <div class="act_as_thead">
+                <div class="act_as_row labels" style="font-weight: bold; font-size: 11x;">
+                    <div class="act_as_cell first_column" style="vertical-align: middle">${_('Name')}</div>
+                    <div class="act_as_cell amount">${_('Code')}</div>
+                    <div class="act_as_cell amount">${_('Number of days')}</div>
+                    <div class="act_as_cell amount">${_('Number of hours')}</div>
+                </div>
+            </div>
+            <div class="act_as_tbody">  
+                <% flag_HE = not_HE(cr,uid,worked_lines_ids) %>
+                <% flag_HN = not_HN(cr,uid,worked_lines_ids) %>
+                
+                %for line in worked_lines_ids:
+                <div class="act_as_row lines">
+                    <div class="act_as_cell">${line.name or '-'}</div>
+                    <div class="act_as_cell amount">${line.code or '-'}</div>                    
+                    <div class="act_as_cell amount">${formatLang(line.number_of_days) or '-'}</div>
+                    <div class="act_as_cell amount">${formatLang(line.number_of_hours) or '-'}</div>
+                </div>
+                %endfor
+                %if flag_HE is False:
+                    <div class="act_as_row lines">
+                        <div class="act_as_cell">${_('DONT EXIST EXTRA HOURS REGISTRED')}</div>
+                        <div class="act_as_cell amount">${'HE'}</div>                    
+                        <div class="act_as_cell amount">${formatLang(0) or '-'}</div>
+                        <div class="act_as_cell amount">${formatLang(0) or '-'}</div>
+                    </div>
+                %endif
+                %if flag_HN is False:
+                    <div class="act_as_row lines">
+                        <div class="act_as_cell">${_('DONT EXIST NORMAL HOURS REGISTRED')}</div>
+                        <div class="act_as_cell amount">${'HN'}</div>                    
+                        <div class="act_as_cell amount">${formatLang(0) or '-'}</div>
+                        <div class="act_as_cell amount">${formatLang(0) or '-'}</div>
+                    </div>
+                %endif
+            </div> 
+            <br></br><br></br>
+            ##Salary Computation
+            <div style="font-size: 16px; font-weight: bold; text-align: left;">${_('Salary Computation')} </div>
+            <div class="act_as_table list_table">
+                <div class="act_as_thead">
+                    <div class="act_as_row labels" style="font-weight: bold; font-size: 11x;">
+                        <div class="act_as_cell first_column" style="vertical-align: middle">${_('Name')}</div>
+                        <div class="act_as_cell">${_('Code')}</div>
+                        <div class="act_as_cell">${_('Category')}</div>
+                        <div class="act_as_cell amount">${_('Base')}</div>
+                        <div class="act_as_cell amount">${_('Amount')}</div>
+                        <div class="act_as_cell amount">${_('Total')}</div>
+                    </div>
+                </div>
+                <div class="act_as_tbody">
+                    <% payslip_lines = get_payslip_lines(cr,uid,payslip.id) %>
+                    %for line in payslip_lines:
+                    <div class="act_as_row lines">
+                        <div class="act_as_cell first_column">${line.name or '-'}</div>
+                        <div class="act_as_cell">${line.code or '-'}</div>                    
+                        <div class="act_as_cell">${line.category_id.name or '-'}</div>
+                        <div class="act_as_cell amount">${line.quantity or '-'}</div>                        
+                        <div class="act_as_cell amount">${company.currency_id.symbol}${formatLang(line.amount) or '-'}</div>
+                        <div class="act_as_cell amount">${company.currency_id.symbol}${formatLang(line.total) or '-'}</div>
+                    </div>
+                    %endfor
+                </div>  
+            </div>    
+        %endfor        
+    </div>   
+    <p style="page-break-after:always"></p>        
+    </body>
+</html>

=== added file 'hr_payroll_report/report/hr_payroll_details_report.py'
--- hr_payroll_report/report/hr_payroll_details_report.py	1970-01-01 00:00:00 +0000
+++ hr_payroll_report/report/hr_payroll_details_report.py	2012-11-07 17:23:39 +0000
@@ -0,0 +1,92 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Addons modules by CLEARCORP S.A.
+#    Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
+#
+#    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 <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import time
+import pooler
+from report import report_sxw
+import locale
+
+class hr_payroll_details_report(report_sxw.rml_parse):
+    def __init__(self, cr, uid, name, context):
+        super(hr_payroll_details_report, self).__init__(cr, uid, name, context=context)
+        self.pool = pooler.get_pool(self.cr.dbname)
+        self.cursor = self.cr
+        self.localcontext.update({
+            'time': time,
+            'cr' : cr,
+            'uid': uid,
+            'get_worked_lines': self.get_worked_lines,
+            'get_payslip_lines':self.get_payslip_lines,
+            'not_HE':self.not_HE,
+            'not_HN':self.not_HN,
+        })
+       
+    def get_worked_lines(self,cr,uid, payslip_id,contract_structure,context=None):
+        worked_line = self.pool.get('hr.payslip.worked_days')
+        worked_lines_ids = worked_line.search(cr,uid,[('payslip_id','=',payslip_id)],context)
+        worked_lines_object = worked_line.browse(cr,uid,worked_lines_ids,context=context)
+            
+        return worked_lines_object
+    
+    def not_HE(self,cr,uid,worked_lines_list):
+        flag = False
+        
+        for line in worked_lines_list:
+            if line.code == 'HE' and line.number_of_hours > 0:
+                flag = True
+        return flag
+    
+    def not_HN(self,cr,uid,worked_lines_list):
+        flag = False
+        
+        for line in worked_lines_list:
+            if line.code == 'HN' and line.number_of_hours > 0:
+                flag = True
+        return flag
+    
+    def get_payslip_lines (self,cr,uid,payslip_id,context=None):
+        payslip_line = self.pool.get('hr.payslip.line')
+        payslip_lines_ids = payslip_line.search(cr,uid,[('slip_id','=',payslip_id)],context)
+        payslip_lines_object = payslip_line.browse(cr,uid,payslip_lines_ids,context=context)
+        payslip_lines_list = []
+        base = 0
+        
+        for line in payslip_lines_object:
+            if line.code == 'BASE':
+                base = line.total
+                payslip_lines_list.append(line)
+            
+            if line.code != 'BASE' and line.code != 'BRUTO':
+                payslip_lines_list.append(line)
+            
+            if line.code == 'BRUTO' and line.total != base:
+                payslip_lines_list.append(line)
+        
+        return payslip_lines_list
+
+#the parameters are the report name and module name 
+report_sxw.report_sxw( 'report.hr_payroll_payslip_details_inherit', 
+                       'hr.payslip',
+                       'addons/hr_payroll_report/report/hr_payroll_details_report.mako', 
+                        parser = hr_payroll_details_report)
+    
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'hr_payroll_report/report/hr_payroll_report.mako'
--- hr_payroll_report/report/hr_payroll_report.mako	2012-11-07 15:17:20 +0000
+++ hr_payroll_report/report/hr_payroll_report.mako	2012-11-07 17:23:39 +0000
@@ -162,7 +162,7 @@
                 </div>
                 <br></br> <br></br><br></br><br></br>
                  <div class="act_as_row" style="text-align:justify;text-justify:inter-word;">
-                    <div style="padding-bottom:5px">${company.payslip_footer}</div>
+                    <div style="padding-bottom:5px">${company.payslip_footer or ''}</div>
                 </div>
             </div>
         </div>


Follow ups