clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00252
[Merge] lp:~dr.clearcorp/openerp-ccorp-addons/hr_payroll_periodic_rule into lp:openerp-ccorp-addons
Diana Rodríguez Martínez has proposed merging lp:~dr.clearcorp/openerp-ccorp-addons/hr_payroll_periodic_rule into lp:openerp-ccorp-addons.
Requested reviews:
CLEARCORP drivers (clearcorp-drivers)
For more details, see:
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/hr_payroll_periodic_rule/+merge/116549
--
https://code.launchpad.net/~dr.clearcorp/openerp-ccorp-addons/hr_payroll_periodic_rule/+merge/116549
Your team CLEARCORP development team is subscribed to branch lp:openerp-ccorp-addons.
=== added directory 'hr_payroll_periodic_rule'
=== added file 'hr_payroll_periodic_rule/__init__.py'
--- hr_payroll_periodic_rule/__init__.py 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/__init__.py 2012-07-24 22:01:20 +0000
@@ -0,0 +1,39 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# __init__.py
+# hr_payroll_periodic_rule
+# First author: Ronald Rubí Chacón <ronald.rubi@xxxxxxxxxxxxxxx> (ClearCorp S.A.)
+# Copyright (c) 2010-TODAY ClearCorp S.A. (http://clearcorp.co.cr). All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are those of the
+# authors and should not be interpreted as representing official policies, either expressed
+# or implied, of ClearCorp S.A..
+#
+##############################################################################
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+import hr_payroll_periodic_rule
+import wizard
+import report
=== added file 'hr_payroll_periodic_rule/__openerp__.py'
--- hr_payroll_periodic_rule/__openerp__.py 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/__openerp__.py 2012-07-24 22:01:20 +0000
@@ -0,0 +1,58 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# __openerp__.py
+# periodic
+# First author: Ronald Rubí Chacón <ronald.rubi@xxxxxxxxxxxxxxx> (ClearCorp S.A.)
+# Copyright (c) 2010-TODAY ClearCorp S.A. (http://clearcorp.co.cr). All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are those of the
+# authors and should not be interpreted as representing official policies, either expressed
+# or implied, of ClearCorp S.A..
+#
+##############################################################################
+
+{
+ 'name': 'hr.payroll.periodic.rule',
+ 'version': '0.1',
+ 'url': 'http://launchpad.net/openerp-ccorp-addons',
+ 'author': 'CLEARCORP S.A.',
+ 'website': 'http://clearcorp.co.cr',
+ 'category': 'Human Resources',
+ 'description': """Clearcorp 'module' for add periodic rules""",
+ 'depends': [
+ 'hr_payroll',
+ 'hr_payroll_account',
+ 'base_module_record',
+ ],
+ 'init_xml': [],
+ 'update_xml': [
+ 'hr_payroll_periodic_rule.xml',
+ 'wizard/hr_payroll_periodic_rule_wizard_view.xml',
+ 'report_menus.xml',
+ 'report/report.xml'
+ ],
+ 'license': 'Other OSI approved licence',
+ 'installable': True,
+ 'active': False,
+}
=== added file 'hr_payroll_periodic_rule/hr_payroll_periodic_rule.py'
--- hr_payroll_periodic_rule/hr_payroll_periodic_rule.py 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/hr_payroll_periodic_rule.py 2012-07-24 22:01:20 +0000
@@ -0,0 +1,543 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# __openerp__.py
+# hr_payroll_periodic_rule
+# First author: Ronald Rubí Chacón <ronald.rubi@xxxxxxxxxxxxxxx> (ClearCorp S.A.)
+# Second author: Diana Rodríguez Martínez <diana.rodriguez@xxxxxxxxxxxxxxx> (Clearcorp S.A)
+# Copyright (c) 2010-TODAY ClearCorp S.A. (http://clearcorp.co.cr). All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are those of the
+# authors and should not be interpreted as representing official policies, either expressed
+# or implied, of ClearCorp S.A..
+#
+##############################################################################
+
+from osv import osv, fields
+import os
+import tools
+from tools.translate import _
+from tools.safe_eval import safe_eval as eval
+
+import pooler
+import calendar
+import netsvc
+import itertools
+
+import time
+from datetime import date
+from datetime import datetime
+from datetime import timedelta
+from dateutil import relativedelta
+from dateutil import parser
+from dateutil import rrule
+from copy import copy
+
+#TO DO: Add pay_date when the contract is weekly to the trunck for 7.0 version
+class hr_contract(osv.osv):
+ _inherit = 'hr.contract'
+ _description = 'Employee Contract'
+ _columns = {
+ #We use numbers because the datetime return the day of the week in a number, where 0 is monday and 6 is sunday.
+ 'weekly_payment_date':fields.selection([
+ ('0','Monday'),
+ ('1','Tuesday'),
+ ('2','Wednesday'),
+ ('3','Thursday'),
+ ('4','Friday'),
+ ('5', 'Saturday'),
+ ('6','Sunday')],'Weekly payment date', selected=True),
+ }
+
+class hr_payslip(osv.osv):
+ _inherit = 'hr.payslip'
+
+ def get_payslip_lines(self, cr, uid, contract_ids, payslip_id, context):
+ rule_obj = self.pool.get('hr.salary.rule')
+ periodic_rule_obj = self.pool.get('hr.payroll.periodic.rule')
+ lines = super(hr_payslip, self).get_payslip_lines(cr, uid, contract_ids, payslip_id, context)
+ periodic_rules = []
+
+ for rule in lines:
+ if rule['amount_select'] == 'periodic_rule':
+ lines.remove(rule)
+ periodic_rules_ids = rule_obj.search(cr, uid, [('code', '=', rule['code'])])
+ periodic_rules += (rule_obj.browse(cr, uid, periodic_rules_ids, context = None))
+
+ all_periodic_rules_ids = periodic_rule_obj.get_all_periodic_rules(cr, uid, periodic_rules, payslip_id)
+
+ if all_periodic_rules_ids is not None:
+ for line in all_periodic_rules_ids:
+ lines.append(line)
+ return lines
+
+hr_payslip()
+
+class one2many_mod2(fields.one2many):
+
+ def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
+ if context is None:
+ context = {}
+ if not values:
+ values = {}
+ res = {}
+ for id in ids:
+ res[id] = []
+ ids2 = obj.pool.get(self._obj).search(cr, user, [(self._fields_id,'in',ids), ('appears_on_periodic_rule', '=', True)], limit=self._limit)
+ for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'):
+ res[r[self._fields_id]].append( r['id'] )
+ return res
+
+class hr_payroll_periodic_rule_type(osv.osv):
+ _name = "hr.payroll.periodic.rule.type"
+ _description = "Periodic rule type"
+ _columns = {
+ 'name' : fields.char('Name', size=64,required=True,readonly=False),
+ 'code' : fields.char('Code', size=64, readonly=False,required=True),
+ 'category': fields.selection([('saving','Saving'),('loan','Loan'),('embargo','Embargo')], 'Category', required = True, readonly=False),
+ 'salary_rule_id': fields.many2one('hr.salary.rule', 'Salary rule', required=True, readonly=False, help="The salary rule for which applied this input"),
+ 'details': fields.char('Details', size = 300, readonly=False),
+ }
+hr_payroll_periodic_rule_type()
+
+class hr_salary_rule(osv.osv):
+ _inherit = 'hr.salary.rule'
+ _columns = {
+ 'amount_select':fields.selection([('percentage','Percentage (%)'),('fix','Fixed Amount'),('periodic_rule','Periodic Rule'),('code','Python Code')],'Amount Type', select=True, required=True, help="The computation method for the rule amount."),
+ 'periodic_rule_type_id':fields.many2one('hr.payroll.periodic.rule.type', 'Periodic rule type', required=True, reandonly=False),
+ }
+
+ #TODO should add some checks on the type of result (should be float)
+ def compute_rule(self, cr, uid, rule_id, localdict, context=None):
+ """
+ :param rule_id: id of rule to compute
+ :param localdict: dictionary containing the environement in which to compute the rule
+ :return: returns a tuple build as the base/amount computed, the quantity and the rate
+ :rtype: (float, float, float)
+ """
+ rule = self.browse(cr, uid, rule_id, context=context)
+ if rule.amount_select == 'fix':
+ try:
+ return rule.amount_fix, eval(rule.quantity, localdict), 100.0
+ except:
+ raise osv.except_osv(_('Error'), _('Wrong quantity defined for salary rule %s (%s)')% (rule.name, rule.code))
+ elif rule.amount_select == 'percentage':
+ try:
+ return eval(rule.amount_percentage_base, localdict), eval(rule.quantity, localdict), rule.amount_percentage
+ except:
+ raise osv.except_osv(_('Error'), _('Wrong percentage base or quantity defined for salary rule %s (%s)')% (rule.name, rule.code))
+ elif rule.amount_select == 'period_rule':
+ try:
+ return eval(rule.amount_percentage_base, localdict), eval(rule.quantity, localdict)
+ except:
+ raise osv.except_osv(_('Error'), _('Wrong percentage base or quantity defined for salary rule %s (%s)')% (rule.name, rule.code))
+ else:
+ try:
+ eval(rule.amount_python_compute, localdict, mode='exec', nocopy=True)
+ return localdict['result'], 'result_qty' in localdict and localdict['result_qty'] or 1.0, 'result_rate' in localdict and localdict['result_rate'] or 100.0
+ except:
+ raise osv.except_osv(_('Error'), _('Wrong python code defined for salary rule %s (%s)')% (rule.name, rule.code))
+hr_salary_rule()
+
+class hr_payroll_periodic_rule(osv.osv):
+
+ def search_salary (self,cr,uid,ids,contract_id,salary_rule_id,context={} ):
+ cr.execute("select max(total) from hr_payslip_line where contract_id=%s and code=%s group by total limit 1",(contract_id,salary_rule_id))
+ res = cr.fetchone()
+ return res[0] if res else 0.0
+
+ def _calculate_total_quota(self,cr,uid,ids,name,arg,context={}):
+ quota = 0.0
+ result = {}
+
+ for periodic_rule_id in ids:
+ periodic_rule = self.browse(cr,uid,periodic_rule_id,context)
+
+ contract_id = periodic_rule.contract_id.id
+ salary_rule_id = periodic_rule.salary_rule_id.code
+
+ if(contract_id != None and salary_rule_id != None):
+ salary_total = self.pool.get('hr.payroll.periodic.rule').search_salary(cr,uid,ids,contract_id,salary_rule_id,context)
+
+ if salary_total > 0.0:
+ if periodic_rule.percentage is True and periodic_rule.rate > 0.0:
+ quota = salary_total * (float(periodic_rule.rate) / 100.0)
+ result[periodic_rule_id] = quota
+ else:
+ result[periodic_rule_id] = periodic_rule.amount_per_month
+
+ return result
+
+ def _calculate_accumulated_ammount (self, cr, uid, ids, name, args, context={}):
+ accumulated_ammount = 0.0
+ result = {}
+
+ for periodic_rule_id in ids:
+ periodic_rule = self.browse(cr,uid,periodic_rule_id,context)
+ periodic_rule_lines_ids = self.pool.get('hr.payroll.periodic.rule.line').search(cr,uid, [('periodic_rule_id','=',periodic_rule.id)])
+ periodic_rule_lines = self.pool.get('hr.payroll.periodic.rule.line').browse(cr,uid,periodic_rule_lines_ids,context={})
+
+ for line in periodic_rule_lines:
+ if line.cancel is True:
+ accumulated_ammount += float(line.total_amount)
+
+ result[periodic_rule_id] = accumulated_ammount
+ return result
+
+ def get_all_periodic_rules(self, cr, uid, periodic_rules, payslip_id,context=None):
+ """
+ @param periodic_rules: list of periodic rules
+ @return: returns a list of tuple (id, sequence) of periodic rules that are maybe to apply
+ """
+ lines = []
+ payslip_line = {}
+ all_lines = []
+ all_periodic_rules = []
+ periodic_rule_obj = self.pool.get('hr.payroll.periodic.rule')
+ amount = 0.0
+
+ for rule in periodic_rules:
+ rule_id = self.pool.get('hr.salary.rule').search(cr, uid, [('code', '=', rule['code'])])
+ periodic_rules_ids = self.pool.get('hr.payroll.periodic.rule').search(cr, uid, [('type_id.salary_rule_id', '=', rule_id)])
+ all_periodic_rules = self.pool.get('hr.payroll.periodic.rule').browse(cr, uid, periodic_rules_ids, context={})
+ payslip = self.pool.get('hr.payslip').browse(cr, uid, payslip_id, context={})
+
+ for periodic_rule in all_periodic_rules:
+ periodic_rule_lines_ids = self.pool.get('hr.payroll.periodic.rule.line').search(cr,uid, [('periodic_rule_id','=',periodic_rule.id)])
+ periodic_rule_lines = self.pool.get('hr.payroll.periodic.rule.line').browse(cr,uid,periodic_rule_lines_ids,context={})
+
+ for line in periodic_rule_lines:
+ if ((line.payment_date >= payslip.date_from and line.payment_date <=payslip.date_to) and line.cancel is False):
+ vals={'cancel':True}
+ periodic_rule_line_obj = self.pool.get('hr.payroll.periodic.rule.line').write(cr, uid, line.id, vals, context=context)
+ amount = line.total_amount
+ payslip_line = periodic_rule_obj.create_payslip_line_dictionary (cr, uid, periodic_rule,payslip,line,rule,amount,context)
+ lines.append(payslip_line)
+
+ for dic in lines:
+ dic_line = ([value for dic['code'], value in dic.items()])
+ all_lines += dic_line
+
+ return all_lines
+
+ def create_payslip_line_dictionary (self, cr, uid, periodic_rule, payslip,line,rule, amount, context=None):
+
+ result_dict = {}
+
+ key = periodic_rule['code']
+
+ periodic_rule_type = self.pool.get('hr.payroll.periodic.rule.type').browse(cr,uid,periodic_rule['type_id'].id,context=context)
+ salary_rule_periodic_type = self.pool.get('hr.salary.rule').browse(cr,uid,periodic_rule_type['salary_rule_id'].id,context=context)
+
+ if periodic_rule.percentage is False:
+ rate = 100
+ else:
+ rate = periodic_rule['rate']
+
+ result_dict[key] = {
+ 'slip_id': payslip.id,
+ 'salary_rule_id': salary_rule_periodic_type.id,
+ 'contract_id' : periodic_rule.contract_id.id,
+ 'code': line['code'],
+ 'name': periodic_rule['name'],
+ 'category_id': salary_rule_periodic_type['category_id'].id,
+ 'sequence': salary_rule_periodic_type['sequence'],
+ 'appears_on_payslip': salary_rule_periodic_type['appears_on_payslip'],
+ 'condition_select': salary_rule_periodic_type['condition_select'],
+ 'condition_python': salary_rule_periodic_type['condition_python'],
+ 'condition_range': salary_rule_periodic_type['condition_range'],
+ 'condition_range_min': salary_rule_periodic_type['condition_range_min'],
+ 'condition_range_max': salary_rule_periodic_type['condition_range_max'],
+ 'amount_fix': salary_rule_periodic_type['amount_fix'],
+ 'amount_python_compute': salary_rule_periodic_type['amount_python_compute'],
+ 'amount_percentage': salary_rule_periodic_type['amount_percentage'],
+ 'amount_percentage_base': salary_rule_periodic_type['amount_percentage_base'],
+ 'register_id': salary_rule_periodic_type['register_id'].id,
+ 'amount': amount,
+ 'employee_id' : payslip.employee_id.id,
+ 'quantity': salary_rule_periodic_type['quantity'],
+ 'rate': rate
+ }
+
+ return result_dict
+
+ def action_pay_dates_periodic_rule(self,cr,uid,ids,context=None):
+
+ lines = []
+ periodic_rule_line = {}
+ code = 1
+ day = 0
+ list_days = []
+
+ for periodic_rule_id in ids:
+ periodic_rule = self.browse(cr,uid,periodic_rule_id,context)
+
+ periodic_rule_lines_ids = self.pool.get('hr.payroll.periodic.rule.line').search(cr,uid, [('periodic_rule_id','=',periodic_rule.id)])
+ periodic_rule_lines = self.pool.get('hr.payroll.periodic.rule.line').browse(cr,uid,periodic_rule_lines_ids,context={})
+
+ if len(periodic_rule_lines) == 0:
+
+ if periodic_rule.contract_id.schedule_pay == 'monthly':
+
+ date_str_start = periodic_rule.date_start
+ date_str_end = periodic_rule.date_end
+
+ dt_obj_start = datetime.strptime(date_str_start, "%Y-%m-%d %H:%M:%S")
+ dt_obj_end = datetime.strptime(date_str_end, "%Y-%m-%d %H:%M:%S")
+
+ if dt_obj_start.day > 15.0 :
+ day = 30
+
+ elif dt_obj_start.day < 15.0:
+ day = 15
+
+ date_start_quota = datetime(dt_obj_start.year,dt_obj_start.month,day)
+ weeks = round(self.number_weeks(cr,uid,date_start_quota,dt_obj_end,context))
+
+ if weeks > 1:
+ weeks = weeks - 1
+
+ if periodic_rule.percentage is False:
+ if(periodic_rule.total_amount > 0.0 and weeks > 0.0):
+ quota = float(periodic_rule.amount_per_month/2.0)
+ amount_per_line = quota
+ else:
+ amount = 0.0
+ else:
+ if(periodic_rule.rate > 0.0 and weeks > 0.0):
+ #------------------------------------------
+ contract_id = periodic_rule.contract_id.id
+ salary_rule_id = periodic_rule.salary_rule_id.code
+ salary_total = self.pool.get('hr.payroll.periodic.rule').search_salary(cr,uid,ids,contract_id,salary_rule_id,context)
+ #------------------------------------------
+ quota = salary_total * (float(periodic_rule.rate) / 100.0)
+ amount_per_line = (quota / 2.0)
+ else:
+ amount = 0.0
+
+ days = 15
+ dates = itertools.islice(self.date_generator(cr,uid,date_start_quota,days,context), weeks)
+ list_days = list(dates)
+
+ for day in list_days:
+ name = 'Payment for the quarterly: '+ datetime(day.year,day.month,day.day).strftime("%Y-%m-%d")
+ payment_day = datetime(day.year,day.month,day.day)
+ periodic_rule_line = self.pool.get('hr.payroll.periodic.rule.line').create_periodic_rule_line(cr,uid,amount_per_line,payment_day,code,name,periodic_rule,context)
+ code += 1
+ lines.append(periodic_rule_line)
+
+ """" ------------------------------------------------------------------------------------------------------------------------"""
+ if periodic_rule.contract_id.schedule_pay == 'weekly':
+ date_str_start = periodic_rule.date_start
+ dt_obj_start = datetime.strptime(date_str_start, "%Y-%m-%d %H:%M:%S")
+ weeks = round(self.date_generator_payment_weekly(cr,uid,dt_obj_start,periodic_rule.contract_id.weekly_payment_date,context))
+ #weeks -= 1
+ if periodic_rule.percentage is False:
+ if(periodic_rule.total_amount > 0.0 and weeks > 0.0):
+ quota = float(periodic_rule.amount_per_month/weeks)
+ amount_per_line = quota
+ else:
+ amount = 0.0
+ else:
+ if(periodic_rule.rate > 0.0 and weeks > 0.0):
+ #------------------------------------------
+ contract_id = periodic_rule.contract_id.id
+ salary_rule_id = periodic_rule.salary_rule_id.code
+ salary_total = self.search_salary(cr,uid,ids,contract_id,salary_rule_id,context)
+ #------------------------------------------
+ quota = salary_total * (float(periodic_rule.rate) / 100.0)
+ amount_per_line = float(quota/weeks)
+ else:
+ amount = 0.0
+
+ days = 5
+ dates = itertools.islice(self.date_generator(cr,uid,dt_obj_start,days,context), weeks)
+ list_days = list(dates)
+
+ for day in list_days:
+ date_str = self.date_of_week(cr,uid,context)[periodic_rule.contract_id.weekly_payment_date]
+ name = 'Payment for the week: ' + datetime(day.year,day.month,day.day).strftime("%Y-%m-%d") + ' (' +date_str+ ')'
+ payment_day = datetime(day.year,day.month,day.day)
+ periodic_rule_line = self.pool.get('hr.payroll.periodic.rule.line').create_periodic_rule_line(cr,uid,amount_per_line,payment_day,code,name,periodic_rule,context)
+ code += 1
+ lines.append(periodic_rule_line)
+
+ for line in lines:
+ periodic_rule.periodic_rule_line_ids.append(line)
+
+ def recalculate_periodic_rule_line (self,cr,uid,ids,context=None):
+ line = self.pool.get('hr.payroll.periodic.rule.line')
+
+ for periodic_rule_id in ids:
+ periodic_rule = self.browse(cr,uid,periodic_rule_id,context)
+ periodic_rule_lines_ids = self.pool.get('hr.payroll.periodic.rule.line').search(cr,uid, [('periodic_rule_id','=',periodic_rule.id)])
+ periodic_rule_lines = self.pool.get('hr.payroll.periodic.rule.line').browse(cr,uid,periodic_rule_lines_ids,context={})
+
+ if len(periodic_rule_lines) > 0:
+ line.unlink(cr, uid, [x.id for x in periodic_rule_lines], context=context)
+ self.action_pay_dates_periodic_rule(cr,uid,ids,context)
+
+ """--------------------------------------------------------------------------------------------------------"""
+
+ def number_weeks(self,cr,uid,date_star,date_end,context=None):
+ weeks = rrule.rrule(rrule.WEEKLY, dtstart=date_star, until=date_end)
+ return weeks.count()
+
+ def date_generator(self,cr,uid,date_start_quota,days,context=None):
+ while True:
+ yield date_start_quota
+ date_start_quota = date_start_quota + timedelta(days=days)
+
+ def date_generator_payment_weekly(self,cr,uid,date_start,day,context=None):
+ cal = calendar.Calendar()
+ cont = 0
+ for date in cal.itermonthdates(date_start.year,date_start.month):
+ if date.weekday() == int(day): #0 monday - 6 sunday
+ cont +=1
+ return cont
+
+ def date_of_week(self,cr,uid,context=None):
+ switch = {
+ '0':'Monday',
+ '1':'Tuesday',
+ '2':'Wednesday',
+ '3':'Thursday',
+ '4':'Friday',
+ '5':'Saturday',
+ '6':'Sunday,'
+ }
+ return switch
+
+ def activate_button(self,cr,uid,ids,context=None):
+ for periodic_rule in ids:
+ periodic_rule = self.browse(cr,uid,periodic_rule_id,context)
+ periodic_rule_lines_ids = self.pool.get('hr.payroll.periodic.rule.line').search(cr,uid, [('periodic_rule_id','=',periodic_rule.id)])
+ periodic_rule_lines = self.pool.get('hr.payroll.periodic.rule.line').browse(cr,uid,periodic_rule_lines_ids,context={})
+
+ if len(periodic_rule_lines) > 0:
+ #if there periodic_rule_lines, the button for create the lines is desactivated
+ return True
+ else:
+ return False
+
+
+ """-----------------------------------------validations-------------------------------------------"""
+ def _check_quota (self, cr, uid, ids, context=None):
+ correcto = True
+ for periodic_rule in self.browse(cr, uid, ids, context=context):
+
+ if periodic_rule.percentage is True:
+ if periodic_rule.rate >= 100:
+ correcto = False
+ raise osv.except_osv(_('Error'), _('Rate cannot be more than or equal to 100 %s')% (periodic_rule.rate))
+ if periodic_rule.rate < 0:
+ correcto = False
+ raise osv.except_osv(_('Error'), _('Rate cannot be less than zero %s')% (periodic_rule.rate))
+
+ else:
+ if periodic_rule.amount_per_month > periodic_rule.total_amount:
+ correcto = False
+ raise osv.except_osv(_('Error'), _('Amount cannot be more than or equal to total amount %s (%s)')% (periodic_rule.amount_per_month,periodic_rule.total_amount))
+ if periodic_rule.amount_per_month <= 0:
+ correcto = False
+ return correcto
+
+ def _check_dates_periodic_rule(self,cr,uid,ids,context=None):
+ correcto = True
+ for periodic_rule in self.browse(cr,uid,ids,context=context):
+ if periodic_rule.date_end < periodic_rule.date_start and periodic_rule.category is not 'saving':
+ correcto = False
+ raise osv.except_osv(_('Error'), _('Date end cannot be more than date start %s (%s)')% (periodic_rule.date_end,periodic_rule.date_start))
+ return correcto
+
+ """-----------------------------------------class definition----------------------------------------"""
+ _name = "hr.payroll.periodic.rule"
+ _description = 'Clearcorp module for add periodic rules'
+ _columns = {
+ 'name': fields.char('Name', size=64, required=True, readonly=False),
+ 'code': fields.char('Code', size=64, readonly=False, help="",required=True),
+ 'contract_id': fields.many2one('hr.contract', 'Contract', required=True, readonly=False, help="The contract for which applied this input"),
+ 'employee_id': fields.related('contract_id','employee_id',type='many2one', string ='Employee',readonly=True, relation='hr.employee'),
+ 'salary_rule_id': fields.many2one('hr.salary.rule', string='Periodic rule based on', required=True, readonly=False, help="The salary rule for which applied this input"),
+ 'category': fields.selection([('saving', 'Saving'),('loan', 'Loan'),('embargo', 'Embargo')], 'Category', required=True, readonly=False),
+ 'date_start': fields.datetime('Date from', required=True, readonly=False),
+ 'date_end': fields.datetime('Date To', readonly=False,required=True),
+ 'percentage': fields.boolean('Percentage'),
+ 'amount_per_month': fields.float('Amount per month', required=True, readonly=False),
+ 'rate': fields.float('Rate %', required=True, readonly=False),
+ 'total_amount':fields.float ('Total amount', required = True, readonly=False, help="Total amount for the loan, saving or embargo"),
+ 'quota':fields.function(_calculate_total_quota, string='Quota per month', readonly=True,type='float'),
+ 'accumulated_ammount': fields.function(_calculate_accumulated_ammount, string='Accumulated ammount', required = True, readonly=True, help="Accumulated amount for the loan, saving or embargo"),
+ 'observation': fields.char('Details', size = 300, readonly=False),
+ 'type_id':fields.many2one('hr.payroll.periodic.rule.type', 'Type', required=True, reandonly=False),
+ 'periodic_rule_line_ids': one2many_mod2('hr.payroll.periodic.rule.line', 'periodic_rule_id', required=True, readonly=False),
+ 'state':fields.selection([('calculated','Calculated'),('recalculated','Recalculated')],'Status',readonly=True, required=True),
+ }
+ _defaults = {
+ 'amount_per_month': 0.0,
+ 'rate':0.0,
+ 'state':'calculated',
+ 'accumulated_ammount': 0.0,
+ }
+
+ _sql_contraints =[
+ ('total_amount','CHECK(total_amount > 0)','Total amount must be more than zero'),
+ ('amount_per_month','CHECK(amount_per_month >= 0)','Amount must be more than zero'),
+ #('unique_code','unique(code)','The periodic rule code must be unique.'),
+ ]
+
+ _constraints = [
+ (_check_quota, 'Error!',['quota']),
+ (_check_dates_periodic_rule, 'Error!',['date_end']),
+ ]
+
+hr_payroll_periodic_rule()
+
+class hr_payroll_periodic_rule_line(osv.osv):
+ _name ='hr.payroll.periodic.rule.line'
+ _description = 'Clearcorp module for add periodic rules lines'
+ _columns = {
+ 'name': fields.char('Name', size=64,readonly=False),
+ 'code': fields.char('Code', size=64, readonly=False, help="",required=True),
+ 'payment_date':fields.datetime('Date from', type='float', required=True, readonly=False),
+ 'total_amount':fields.float('Quota', required=True,readonly=False),
+ 'periodic_rule_id': fields.many2one('hr.payroll.periodic.rule','Periodic rule',readonly=False),
+ 'appears_on_periodic_rule': fields.boolean('Appears on periodic rule line', help="Used for the display of rule on payslip"),
+ 'cancel': fields.boolean('Cancel'),
+ }
+
+ def create_periodic_rule_line (self,cr,uid,amount_per_line,pay_date,code,name,periodic_rule,context=None):
+ periodic_rule_line = self.pool.get('hr.payroll.periodic.rule.line')
+ periodic_rule_line.create(cr, uid, {
+ 'name': name,
+ 'code': code,
+ 'payment_date': pay_date,
+ 'periodic_rule_id': periodic_rule.id,
+ 'total_amount':amount_per_line,
+ 'appears_on_periodic_rule': True,
+ }, context=context)
+
+ return periodic_rule_line
+hr_payroll_periodic_rule_line()
+
+
=== added file 'hr_payroll_periodic_rule/hr_payroll_periodic_rule.xml'
--- hr_payroll_periodic_rule/hr_payroll_periodic_rule.xml 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/hr_payroll_periodic_rule.xml 2012-07-24 22:01:20 +0000
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!-- Salary Rules -->
+ <record id="hr_salary_rule_periodic_rule_form" model="ir.ui.view">
+ <field name="name">hr.salary.rule.periodic.rule.form</field>
+ <field name="model">hr.salary.rule</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="hr_payroll.hr_salary_rule_form"/>
+ <field name="arch" type="xml">
+ <data>
+ <field name="amount_percentage_base" position="replace" >
+ <field name="amount_percentage_base" attrs="{'invisible':['|',('amount_select','=','code'),('amount_select','=','fix')], 'required': [('amount_select','!=','code'),('amount_select','!=','fix')]}"/>
+ </field>
+ </data>
+ </field>
+ </record>
+ <!-- End Salary Rules -->
+
+ <!-- Contract -->
+ <record id="hr_contract_periodic_rule_form" model="ir.ui.view">
+ <field name="name">hr.contract.periodic.rule.form</field>
+ <field name="model">hr.contract</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="hr_contract.hr_contract_view_form"/>
+ <field name="arch" type="xml">
+ <data>
+ <field name="type_id" position="after" >
+ <field name="weekly_payment_date" attrs="{'invisible':[('schedule_pay','!=','weekly')], 'required': [('schedule_pay','=','weekly')]}"/>
+ </field>
+ </data>
+ </field>
+ </record>
+ <!-- End Contract -->
+
+ <!-- Periodic rule -->
+ <!-- Periodic Rule FORM-->
+ <record id="hr_payroll_periodic_rule_form" model="ir.ui.view">
+ <field name="name">hr.payroll.periodic.rule.form</field>
+ <field name="model">hr.payroll.periodic.rule</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Periodic rule">
+ <separator colspan="4" string="Basic information"/>
+ <group col="6" colspan="6">
+ <field name="name"/>
+ <field name="code"/>
+ <field name="category"/>
+ <field name="contract_id" />
+ <field name="type_id"/>
+ </group>
+ <separator colspan="4" string="Date"/>
+ <group col="4" colspan="6">
+ <field name="date_start" />
+ <field name="date_end"/>
+ </group>
+ <separator colspan="4" string="Amount"/>
+ <group col="2" colspan="6">
+ <field name="salary_rule_id"/>
+ <field name="total_amount"/>
+ <field name="percentage" />
+ <field name="rate" attrs="{'invisible':[('percentage','=',False)]}"/>
+ <field name="amount_per_month" attrs="{'invisible':[('percentage','=',True)]}" />
+ <field name="quota" attrs="{'invisible':[('percentage','=',False)]}" />
+ <field name="accumulated_ammount"/>
+ </group>
+ <separator colspan="4" string=""/>
+ <notebook colspan="2">
+ <page string="Periodic rule lines">
+ <field name="periodic_rule_line_ids" colspan="4" nolabel="1" widget="one2many_list"></field>
+ </page>
+ <page string="Observations">
+ <field name="observation" colspan="4" nolabel="1" rowspan="10"/>
+ </page>
+ </notebook>
+ <group colspan="4" col="4">
+ <field name="state"/>
+ <button name="action_pay_dates_periodic_rule" type="object" icon="gtk-execute" string="Generate periodic rule lines" />
+ <!--
+ <button name="recalculate_periodic_rule_line" string="Recalculate periodic rule lines" type="object" icon="gtk-ok" attrs="{'readonly':[('state', '=', 'calculated')]}" />
+ <button string="Confirm" type="workflow" name="action_confirm" states="draft" />
+ <button string="Mark as done" type="workflow" name="action_done" states="confirmed" />
+ <button string="Reset to draft" type="workflow" name="action_draft" states="confirmed,done" />
+ -->
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <!-- Periodic Rule TREE-->
+ <record id="hr_payroll_periodic_rule_tree" model="ir.ui.view">
+ <field name="name">hr.payroll.periodic.rule.tree</field>
+ <field name="model">hr.payroll.periodic.rule</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="periodic rule">
+ <field name="name"/>
+ <field name="code"/>
+ <field name="category" />
+ <field name="contract_id" />
+ <field name="employee_id"/>
+ <field name="date_start" />
+ <field name="date_end" />
+ <field name="type_id"/>
+ </tree>
+ </field>
+ </record>
+
+ <!-- Periodic Rule SEARCH-->
+ <record id="view_hr_payroll_periodic_rule_filter" model="ir.ui.view">
+ <field name="name">periodic rule</field>
+ <field name="model">hr.payroll.periodic.rule</field>
+ <field name="type">search</field>
+ <field name="arch" type="xml">
+ <search string="Periodic Rule">
+ <group col="8" colspan="4">
+ <field name="name"/>
+ <field name="code"/>
+ <field name="date_start"/>
+ <field name="date_end"/>
+ </group>
+ <newline/>
+ <group col="8" colspan="4" expand="0" string="Group By...">
+ <filter string="Category" icon="terp-stock_symbol-selection" name="category" context="{'group_by':'category'}"/>
+ <separator orientation="vertical"/>
+ <filter string="Contract" name="contract_id" icon="terp-personal" context="{'group_by':'contract_id'}"/>
+ <separator orientation="vertical"/>
+ <filter string="Type" name="type_id" icon="terp-folder-yellow" context="{'group_by':'type_id'}"/>
+ </group>
+ </search>
+ </field>
+ </record>
+
+ <!-- Periodic rule window -->
+ <record id="open_module_tree_hr_payroll_periodic_rule" model="ir.actions.act_window">
+ <field name="name">Periodic Rule</field>
+ <field name="res_model">hr.payroll.periodic.rule</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="search_view_id" ref="view_hr_payroll_periodic_rule_filter"/>
+ <field name="help">You can include savings, loans, embargos, fundings.</field>
+ </record>
+
+ <!-- Periodic rule type -->
+ <!-- Periodic rule type tree -->
+ <record id="hr_payroll_periodic_rule_category_tree" model="ir.ui.view">
+ <field name="name">hr.payroll.periodic.rule.type.tree</field>
+ <field name="model">hr.payroll.periodic.rule.type</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="periodic rule type">
+ <field name="code"/>
+ <field name="name"/>
+ <field name="category" />
+ </tree>
+ </field>
+ </record>
+
+ <!--Periodic rule type search -->
+ <record id="view_hr_payroll_periodic_rule_type_filter" model="ir.ui.view">
+ <field name="name">periodic rule type</field>
+ <field name="model">hr.payroll.periodic.rule.type</field>
+ <field name="type">search</field>
+ <field name="arch" type="xml">
+ <search string="Periodic Rule Type">
+ <group col="8" colspan="4">
+ <field name="code"/>
+ <field name="name"/>
+ </group>
+ <newline/>
+ <group col="8" colspan="4" expand="0" string="Group By...">
+ <filter string="Category" icon="terp-stock_symbol-selection" name="category" context="{'group_by':'category'}"/>
+ </group>
+ </search>
+ </field>
+ </record>
+
+ <!-- Periodic rule type form -->
+ <record id="hr_payroll_periodic_rule_type_form" model="ir.ui.view">
+ <field name="name">hr.payroll.periodic.rule.type.form</field>
+ <field name="model">hr.payroll.periodic.rule.type</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Periodic rule tyoe">
+ <group col="4" colspan="4">
+ <field name="code"/>
+ <field name="name"/>
+ <field name="category"/>
+ <field name="salary_rule_id"/>
+ </group>
+ <notebook colspan="4">
+ <page string="Details">
+ <field name="details" colspan="2" nolabel="1" rowspan="10"/>
+ </page>
+ </notebook>
+ </form>
+ </field>
+ </record>
+
+ <!-- Periodic rule type window -->
+ <record id="open_module_tree_hr_payroll_periodic_rule_type" model="ir.actions.act_window">
+ <field name="name">Periodic Rule Type</field>
+ <field name="res_model">hr.payroll.periodic.rule.type</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">tree,form</field>
+ <field name="search_view_id" ref="view_hr_payroll_periodic_rule_type_filter"/>
+ </record>
+
+ <!-- Periodic rule line tree -->
+ <record id="hr_periodic_rule_line_tree" model="ir.ui.view">
+ <field name="name">hr.periodic.rule.line.tree</field>
+ <field name="model">hr.periodic.rule.line</field>
+ <field name="type">tree</field>
+ <field name="arch" type="xml">
+ <tree string="Periodic rule line">
+ <field name="name"/>
+ <field name="payment_date"/>
+ <field name="total_amount"/>
+ </tree>
+ </field>
+ </record>
+
+ <!-- Menu option -->
+ <menuitem id="menu_hr_root_periodic_rule" parent="hr.menu_hr_root" name="Periodic Rule" sequence="2"/>
+ <menuitem action="open_module_tree_hr_payroll_periodic_rule" id="menu_hr_payroll_periodic_rule_tree" parent="menu_hr_root_periodic_rule" sequence="1" />
+ <menuitem action="open_module_tree_hr_payroll_periodic_rule_type" id="menu_hr_payroll_periodic_rule_type_tree" parent="menu_hr_root_periodic_rule" sequence="2" />
+ <!-- End periodic Rule -->
+ </data>
+</openerp>
=== added directory 'hr_payroll_periodic_rule/i18n'
=== added file 'hr_payroll_periodic_rule/i18n/es_CR.po'
--- hr_payroll_periodic_rule/i18n/es_CR.po 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/i18n/es_CR.po 2012-07-24 22:01:20 +0000
@@ -0,0 +1,290 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * hr_payroll_periodic_rule
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-06-20 23:45+0000\n"
+"PO-Revision-Date: 2012-06-20 23:45+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+#: field:hr.payroll.periodic.rule,category:0
+#: view:hr.payroll.periodic.rule.type:0
+#: field:hr.payroll.periodic.rule.type,category:0
+msgid "Category"
+msgstr "Categoría"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+msgid "periodic rule"
+msgstr "Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,recess_amount:0
+msgid "Recess amount"
+msgstr "Monto o (%) a rebajar"
+
+#. module: hr_payroll_periodic_rule
+#: model:ir.actions.act_window,help:hr_payroll_periodic_rule.open_module_tree_hr_payroll_periodic_rule
+msgid "You can include savings, loans, embargos, fundings."
+msgstr "Usted puede incluir ahorros, préstamos, embargos, financiamiento"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+#: view:hr.payroll.periodic.rule.type:0
+msgid "Group By..."
+msgstr "Agrupado por ..."
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+#: field:hr.payroll.periodic.rule,details:0
+msgid "Details"
+msgstr "Detalles"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,employee_id:0
+msgid "Employee"
+msgstr "Empleado"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule.type:0
+msgid "Periodic rule tyoe"
+msgstr "Tipo de regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,salary_rule_id:0
+msgid "Salary rule"
+msgstr "Regla de salario"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:259
+#, python-format
+msgid "Recess amount cannot be less than zero %s"
+msgstr "Monto de rebajo no puede ser menor a cero %s"
+
+#. module: hr_payroll_periodic_rule
+#: help:hr.payroll.periodic.rule,recess_amount:0
+msgid "If you choose rate, this amount is a percentage (0 - 99)"
+msgstr "Si usted escoge porcentage debe estar entre 0 - 99"
+
+#. module: hr_payroll_periodic_rule
+#: model:ir.model,name:hr_payroll_periodic_rule.model_hr_salary_rule
+msgid "hr.salary.rule"
+msgstr "hr.salary.rule"
+
+#. module: hr_payroll_periodic_rule
+#: help:hr.payroll.periodic.rule,total_amount:0
+msgid "Total amount for the loan, saving or embargo"
+msgstr "Monto total para el préstamo, ahorro o embargo"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+#: field:hr.payroll.periodic.rule,type_id:0
+msgid "Type"
+msgstr "Tipo"
+
+#. module: hr_payroll_periodic_rule
+#: model:ir.model,name:hr_payroll_periodic_rule.model_hr_payroll_periodic_rule_type
+msgid "Periodic rule type"
+msgstr "Tipo de Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: help:hr.payroll.periodic.rule,salary_rule_id:0
+msgid "The salary rule for which applied this input"
+msgstr "La regla de salario para esta Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,quota:0
+msgid "Quota"
+msgstr "Cuota"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:115
+#, python-format
+msgid "Wrong python code defined for salary rule %s (%s)"
+msgstr "Código de python erróneo definido para esta regla de salario %s (%s)"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:264
+#, python-format
+msgid "Recess amount cannot be more than or equal to total amount %s (%s)"
+msgstr "Monto de rebajo no puede ser mayor o igual al monto total %s (%s)"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+msgid "Date"
+msgstr "Fecha"
+
+#. module: hr_payroll_periodic_rule
+#: model:ir.model,name:hr_payroll_periodic_rule.model_hr_payslip
+msgid "Pay Slip"
+msgstr "Nómina"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+msgid "Basic information"
+msgstr "Información básica"
+
+#. module: hr_payroll_periodic_rule
+#: help:hr.payroll.periodic.rule,contract_id:0
+msgid "The contract for which applied this input"
+msgstr "El contrato que aplica para esta Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: selection:hr.payroll.periodic.rule,category:0
+#: selection:hr.payroll.periodic.rule.type,category:0
+msgid "Embargo"
+msgstr "Embargo"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+#: model:ir.actions.act_window,name:hr_payroll_periodic_rule.open_module_tree_hr_payroll_periodic_rule
+#: model:ir.ui.menu,name:hr_payroll_periodic_rule.menu_hr_payroll_periodic_rule_tree
+#: model:ir.ui.menu,name:hr_payroll_periodic_rule.menu_hr_root_periodic_rule
+msgid "Periodic Rule"
+msgstr "Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,name:0
+#: field:hr.payroll.periodic.rule.type,name:0
+msgid "Name"
+msgstr "Nombre"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule.type:0
+#: model:ir.actions.act_window,name:hr_payroll_periodic_rule.open_module_tree_hr_payroll_periodic_rule_type
+#: model:ir.ui.menu,name:hr_payroll_periodic_rule.menu_hr_payroll_periodic_rule_type_tree
+msgid "Periodic Rule Type"
+msgstr "Tipo de Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: constraint:hr.payslip:0
+msgid "Payslip 'Date From' must be before 'Date To'."
+msgstr "Boleta ' Fecha Desde' pago debe ser antes de 'Fecha a'."
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,total_amount:0
+msgid "Total amount"
+msgstr "Monto total"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:99
+#, python-format
+msgid "Wrong quantity defined for salary rule %s (%s)"
+msgstr "Cantidad errónea definida para esta regla de salario %s (%s)"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+msgid "Periodic rule"
+msgstr "Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+#: field:hr.payroll.periodic.rule,contract_id:0
+msgid "Contract"
+msgstr "Contrato"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,date_end:0
+msgid "Date To"
+msgstr "Fecha final"
+
+#. module: hr_payroll_periodic_rule
+#: constraint:hr.payroll.periodic.rule:0
+msgid "Error!"
+msgstr "Error!"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule:0
+msgid "Amount"
+msgstr "Monto"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:99
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:104
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:109
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:115
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:256
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:259
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:264
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:267
+#, python-format
+msgid "Error"
+msgstr "Error"
+
+#. module: hr_payroll_periodic_rule
+#: selection:hr.payroll.periodic.rule,category:0
+#: selection:hr.payroll.periodic.rule.type,category:0
+msgid "Saving"
+msgstr "Ahorro"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,pay_day:0
+msgid "Pay date"
+msgstr "Día de pago"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule.type,code:0
+msgid "Code"
+msgstr "Código"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:267
+#, python-format
+msgid "Recess amount cannot be less more than or equal to zero %s (%s)"
+msgstr "Monto de rebajo no puede ser menor o igual que cero %s (%s)"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,ref:0
+msgid "Reference"
+msgstr "Referencia"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:256
+#, python-format
+msgid "Recess amount cannot be more than or equal to 100 %s"
+msgstr "Porcentaje de rebajo no puede ser mayor o igual a 100 %s"
+
+#. module: hr_payroll_periodic_rule
+#: view:hr.payroll.periodic.rule.type:0
+msgid "periodic rule type"
+msgstr "Tipo de Regla periódica"
+
+#. module: hr_payroll_periodic_rule
+#: selection:hr.payroll.periodic.rule,category:0
+#: selection:hr.payroll.periodic.rule.type,category:0
+msgid "Loan"
+msgstr "Préstamo"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,rate:0
+msgid "Rate"
+msgstr "Porcentaje"
+
+#. module: hr_payroll_periodic_rule
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:104
+#: code:addons/hr_payroll_periodic_rule/hr_payroll_periodic_rule.py:109
+#, python-format
+msgid "Wrong percentage base or quantity defined for salary rule %s (%s)"
+msgstr "Porcentaje base o cantidad errónea definida para esta regla de salario %s (%s)"
+
+#. module: hr_payroll_periodic_rule
+#: field:hr.payroll.periodic.rule,date_start:0
+msgid "Date from"
+msgstr "Fecha inicio"
+
+#. module: hr_payroll_periodic_rule
+#: model:ir.model,name:hr_payroll_periodic_rule.model_hr_payroll_periodic_rule
+#: model:ir.model,name:hr_payroll_periodic_rule.model_hr_payroll_perioic_rule
+msgid "Clearcorp module for add periodic rules"
+msgstr "Módulo de Clearcorp para añadir reglas de período"
+
=== added directory 'hr_payroll_periodic_rule/report'
=== added file 'hr_payroll_periodic_rule/report/__init__.py'
--- hr_payroll_periodic_rule/report/__init__.py 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/report/__init__.py 2012-07-24 22:01:20 +0000
@@ -0,0 +1,1 @@
+import hr_payroll_periodic_rule_report
=== added file 'hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.mako'
--- hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.mako 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.mako 2012-07-24 22:01:20 +0000
@@ -0,0 +1,219 @@
+<!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">${css}</style>
+</head>
+<body>
+ <%setLang(user.context_lang)%>
+ <div class="header">
+ <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;">Reglas periódicas </div>
+ </div>
+ <div class="act_as_table data_table" style="margin-top:10px;">
+ <div class="act_as_row labels" style = "font-size: 12px;">
+ <div class="act_as_cell">
+ %if get_type_filter(data) == 'date':
+ ${_('Dates Filter')}
+ %else:
+ ${_('Filter')}
+ %endif
+ </div>
+ <% type = get_type_report(data)%>
+ %if type == 'contract':
+ <div class="act_as_cell">
+ ${_('Contract')}
+ </div>
+ <div class="act_as_cell">
+ ${_('Employee')}
+ </div>
+ %elif type == 'category':
+ <div class="act_as_cell">
+ ${_('Type report')}
+ </div>
+ <div class="act_as_cell">
+ ${_('Category')}
+ </div>
+ %elif type == 'periodic_rule':
+ <div class="act_as_cell">
+ ${_('Type report')}
+ </div>
+ <div class="act_as_cell">
+ ${_('Type periodic rule')}
+ </div>
+ %endif
+ </div>
+ <div class="act_as_row" style = "font-size: 12px;">
+ <div class="act_as_cell">
+ ${_('From:')}
+ %if get_type_filter(data) == 'date':
+ ${formatLang(get_date_start(data), date=True) if get_date_start(data) else u'' }
+ %else:
+ ${_('No filter')}
+ %endif
+ ${_('To:')}
+ %if get_type_filter(data) == 'date':
+ ${ formatLang(get_date_end(data), date=True) if get_date_end(data) else u'' }
+ %else:
+ ${_('No filter')}
+ %endif
+ </div>
+ %if type == 'contract':
+ <div class="act_as_cell">
+ <%contract_id = get_contract_id(data)%>
+ ${contract_id[1]}
+ </div>
+ <div class="act_as_cell">
+ <%employee_id = get_employee(data)%>
+ ${employee_id}
+ </div>
+ %elif type == 'category':
+ <div class="act_as_cell">
+ <%type_report_id = get_type_report(data) %>
+ ${type_report_id}
+ </div>
+ <div class="act_as_cell">
+ <%category = get_category(data) %>
+ ${category}
+ </div>
+ %elif type == 'periodic_rule':
+ <div class="act_as_cell">
+ <%type_report_id = get_type_report(data) %>
+ ${_('Periodic rule types')}
+ </div>
+ <div class="act_as_cell">
+ <%type_periodic_rule = get_type_id(data) %>
+ ${type_periodic_rule[1]}
+ </div>
+ %endif
+ </div>
+ </div>
+ <% get_lines_report = get_lines(data) %>
+ %for line in get_lines_report:
+ %if len(line) > 0:
+ <div class="account_title bg" style="width: 100%; margin-top: 15px; font-size: 12px;">
+ %if line['category'] == 'saving':
+ ${_('Saving')}
+ %elif line['category'] =='loan':
+ ${_('Loan')}
+ %elif line['category'] == 'embargo':
+ ${_('Embargo')}
+ %else:
+ ${_('Other')}
+ %endif
+ </div>
+ <div class="act_as_table list_table" style="margin-top: 5px;">
+ <div class="act_as_thead">
+ <div class="act_as_row labels no_wrap">
+ ## Contract
+ <div class="act_as_cell first_column">${_('Contract')}</div>
+ ## Employee
+ <div class="act_as_cell">${_('Employee')}</div>
+ ## Date start
+ <div class="act_as_cell">${_('Date start')}</div>
+ ## Date end
+ <div class="act_as_cell">${_('Date end')}</div>
+ ## Amount
+ <div class="act_as_cell last_column amount">${_('Total amount')}</div>
+ ## Amount per month / percentage
+ %if line['percentage']:
+ <div class="act_as_cell last_column amount">${_('Percentage per month')}</div>
+ %else:
+ <div class="act_as_cell last_column amount">${_('Amount per month')}</div>
+ %endif
+ ## Quota
+ <div class="act_as_cell last_column amount">${_('Quota')}</div>
+ ## Accumulated ammount
+ <div class="act_as_cell last_column amount">${_('Accumulated ammount')}</div>
+ </div>
+ </div>
+ <div class="act_as_tbody">\
+ <div class="act_as_row lines">
+ ## Contract
+ <div class="act_as_cell first_column no_wrap">${line['contract_id']}</div>
+ ## Employee
+ <div class="act_as_cell no_wrap">${line['employee_id']}</div>
+ ## Date start
+ <div class="act_as_cell no_wrap">${formatLang(line['date_start'], date=True)}</div>
+ ## Date end
+ <div class="act_as_cell no_wrap">${formatLang(line['date_end'], date=True)}</div>
+ ## Total amount
+ <div class="act_as_cell amount">${formatLang(line['total_amount'])}</div>
+ ## Amount /percentage per month
+ %if line['percentage']:
+ <div class="act_as_cell amount">${line['amount_per_month']}${_('%')}</div>
+ %else:
+ <div class="act_as_cell amount">${formatLang(line['amount_per_month'])}</div>
+ %endif
+ ## Quota
+ <div class="act_as_cell amount">${formatLang(line['quota'])}</div>
+ ## Accumulated Amount
+ <div class="act_as_cell last_column amount">${formatLang(line['accumulated_ammount'])}</div>
+ </div>
+ </div>
+ </div>
+ %if data['form']['detail']:
+ <div class="account_title bg" style="width: 100%; margin-top: 15px; font-size: 12px;">
+ ${_('Detail')}
+ </div>
+ %endif
+ <div class="act_as_table list_table" style="margin-top: 5px;">
+ <% lines_periodic_rule = get_periodic_rule_lines_report(line) %>
+ %if data['form']['detail']:
+ <div class="act_as_thead">
+ <div class="act_as_row labels no_wrap">
+ ## Name
+ <div class="act_as_cell" style="padding-left:10px">${_('Payment')}</div>
+ ## Payment date
+ <div class="act_as_cell">${_('Payment date')}</div>
+ ## Total amount
+ <div class="act_as_cell last_column amount">${_('Total amount')}</div>
+ ## Accumulated ammount
+ <div class="act_as_cell last_column amount">${_('State')}</div>
+ </div>
+ </div>
+ <div class="act_as_tbody">
+ %for line_periodic in lines_periodic_rule:
+ <div class="act_as_row lines">
+ ## name
+ <div class="act_as_cell first_column no_wrap" style="padding-left:10px">${line_periodic['name']}</div>
+ ## payment_date
+ <div class="act_as_cell">${formatLang(line_periodic['payment_date'], date=True)}</div>
+ ## total_amount
+ <div class="act_as_cell amount">${formatLang(line_periodic['total_amount'])}</div>
+ ## canceled
+ %if line_periodic['cancel']:
+ <div class="act_as_cell amount">${_('Canceled')}</div>
+ %else:
+ <div class="act_as_cell amount">${_('Pendient')}</div>
+ %endif
+ </div>
+ %endfor
+ </div>
+ %endif
+ </div>
+ %endif
+ <% get_total_lines = get_total_periodic_rules(get_lines_report,lines_periodic_rule) %>
+ <div class="account_title bg" style="width: 100%; margin-top: 15px; font-size: 12px;">
+ ${_('Totals')}
+ </div>
+ <div align="right">
+ <div class="act_as_table data_table no_wrap results left" style="margin-top:20px; margin-bottom: 10px; width:500px">
+ <div class="act_as_row">
+ <div class="act_as_cell ">${_('Total amount')}</div>
+ <div class="act_as_cell amount">${formatLang(get_total_lines['total_amount'])}</div>
+ </div>
+ <div class="act_as_row">
+ <div class="act_as_cell">${_('Accumulated amount')}</div>
+ <div class="act_as_cell amount">${formatLang(get_total_lines['accumulated_amount'])}</div>
+ </div>
+ <div class="act_as_row">
+ <div class="act_as_cell ">${_('Pendient amount')}</div>
+ <div class="act_as_cell amount">${formatLang(get_total_lines['pendient_amm'])}</div>
+ </div>
+ </div>
+ </div>
+ %endfor
+
+</body>
+</html>
+
=== added file 'hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.py'
--- hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.py 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.py 2012-07-24 22:01:20 +0000
@@ -0,0 +1,349 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from report import report_sxw
+from account_financial_report_webkit.report.common_reports import CommonReportHeaderWebkit
+from copy import copy
+import pooler
+from pprint import PrettyPrinter
+
+class hr_payroll_periodic_rule_report_parser(report_sxw.rml_parse,CommonReportHeaderWebkit):
+
+ ####################From getter helper #####################################
+ def get_contract_id(self,data):
+ return self._get_form_param('contract_id',data)
+
+ def get_category(self,data):
+ return self._get_form_param('category', data)
+
+ def get_start_date(self,data):
+ return self._get_form_param('date_start',data)
+
+ def get_end_date (self, data):
+ return self._get_form_param('date_end',data)
+
+ def get_type_id (self, data):
+ return self._get_form_param('type_id', data)
+
+ def get_type_report (self, data):
+ return self._get_form_param('type_report', data)
+
+ def get_detail (self,data):
+ return self._get_form_param ('detail', data)
+
+ def get_type_filter(self,data):
+ return self._get_form_param('type_filter', data)
+
+ #################################################################################
+
+ def __init__(self, cursor, uid, name, context):
+ super(hr_payroll_periodic_rule_report_parser, self).__init__(cursor, uid, name, context=context)
+ self.pool = pooler.get_pool(self.cr.dbname)
+ self.cursor = self.cr
+
+ self.localcontext.update({
+ 'cr' : cursor,
+ 'uid': uid,
+ 'get_contract_id': self.get_contract_id,
+ 'get_category': self.get_category,
+ 'get_date_start': self.get_start_date,
+ 'get_date_end': self.get_end_date,
+ 'get_type_id': self.get_type_id,
+ 'get_type_report': self.get_type_report,
+ 'get_detail': self.get_detail,
+ 'get_type_filter': self.get_type_filter,
+ 'get_lines': self.get_lines,
+ 'get_periodic_rule_lines_report': self.get_periodic_rule_lines_report,
+ 'get_employee': self.get_employee,
+ 'get_total_periodic_rules': self.get_total_periodic_rules,
+ })
+ self.context = context
+
+ ########################################################################################
+
+ def get_employee (self, data):
+ periodic_rules_id = self.pool.get('hr.payroll.periodic.rule').search(self.cr, self.uid, [('contract_id','=',data['form']['contract_id'])])[0]
+
+ if periodic_rules_id:
+ periodic_rule_obj = self.pool.get('hr.payroll.periodic.rule').browse(self.cr, self.uid, periodic_rules_id, context = None)
+ return periodic_rule_obj.employee_id.name
+ else:
+ return 'Employee not found'
+
+ def get_periodic_rule_category_report(self,data):
+ lines = []
+ vals = {}
+ periodic_rules_ids = self.pool.get('hr.payroll.periodic.rule').search(self.cr, self.uid, [('category','=',data['form']['category'])])
+
+ if periodic_rules_ids:
+ for periodic_rule in self.pool.get('hr.payroll.periodic.rule').browse(self.cr, self.uid, periodic_rules_ids, context = None):
+ if data['form']['type_filter'] == 'date':
+ if periodic_rule.date_start >= data['form']['date_start'] and periodic_rule.date_end <= data['form']['date_end']:
+ if periodic_rule.percentage is True:
+ amount = periodic_rule.rate
+ quota = periodic_rule.quota
+ else:
+ amount = periodic_rule.quota
+ quota = periodic_rule.quota
+
+ vals = {
+ 'name': periodic_rule.name,
+ 'contract_id': periodic_rule.contract_id.id,
+ 'employee_id': periodic_rule.employee_id.name,
+ 'date_start': periodic_rule.date_start,
+ 'date_end': periodic_rule.date_end,
+ 'amount_per_month': periodic_rule.amount_per_month,
+ 'rate': periodic_rule.rate,
+ 'total_amount': periodic_rule.total_amount,
+ 'amount_per_month':amount,
+ 'quota': quota,
+ 'accumulated_ammount': periodic_rule.quota,
+ 'percentage':periodic_rule.percentage,
+ 'id': periodic_rule.id,
+ 'category': periodic_rule.category,
+ }
+ else:
+ if periodic_rule.percentage is True:
+ amount = periodic_rule.rate
+ quota = periodic_rule.quota
+ else:
+ amount = periodic_rule.quota
+ quota = periodic_rule.quota
+
+ vals = {
+ 'name': periodic_rule.name,
+ 'contract_id': periodic_rule.contract_id.id,
+ 'employee_id': periodic_rule.employee_id.name,
+ 'date_start': periodic_rule.date_start,
+ 'date_end': periodic_rule.date_end,
+ 'amount_per_month': periodic_rule.amount_per_month,
+ 'rate': periodic_rule.rate,
+ 'total_amount': periodic_rule.total_amount,
+ 'amount_per_month':amount,
+ 'quota': quota,
+ 'accumulated_ammount': periodic_rule.quota,
+ 'percentage':periodic_rule.percentage,
+ 'id': periodic_rule.id,
+ 'category': periodic_rule.category,
+ }
+
+ lines.append(copy(vals))
+ return lines
+
+ def get_periodic_rule_lines_report(self,periodic_rule_obj):
+
+ lines = []
+ vals = {}
+
+ if periodic_rule_obj:
+ periodic_rule_lines_ids = self.pool.get('hr.payroll.periodic.rule.line').search(self.cr, self.uid, [('periodic_rule_id','=',periodic_rule_obj['id'])])
+ periodic_rule_lines_obj = self.pool.get('hr.payroll.periodic.rule.line').browse(self.cr, self.uid, periodic_rule_lines_ids, context = None)
+
+ for periodic_rule_line in periodic_rule_lines_obj:
+ vals = {
+ 'name': periodic_rule_line.name,
+ 'code': periodic_rule_line.code,
+ 'payment_date':periodic_rule_line.payment_date,
+ 'total_amount':periodic_rule_line.total_amount,
+ 'periodic_rule_id': periodic_rule_line.periodic_rule_id.id,
+ 'appears_on_periodic_rule': periodic_rule_line.appears_on_periodic_rule,
+ 'cancel': periodic_rule_line.cancel,
+ }
+ lines.append(copy(vals))
+ #vals.insert('total',0)
+ return lines
+
+ def get_periodic_rule_contract_report(self,data):
+ lines = []
+ vals = {}
+
+ if data['form']['contract_id'] and data['form']['category']:
+ periodic_rules_ids = self.pool.get('hr.payroll.periodic.rule').search(self.cr, self.uid, [('contract_id','=',data['form']['contract_id']),('category','=',data['form']['category'])])
+ else:
+ periodic_rules_ids = self.pool.get('hr.payroll.periodic.rule').search(self.cr, self.uid, [('contract_id','=',data['form']['contract_id'])])
+
+ if periodic_rules_ids:
+ for periodic_rule in self.pool.get('hr.payroll.periodic.rule').browse(self.cr, self.uid, periodic_rules_ids, context = None):
+ if data['form']['type_filter'] == 'date':
+ if periodic_rule.date_start >= data['form']['date_start'] and periodic_rule.date_end <= data['form']['date_end']:
+ if periodic_rule.percentage is True:
+ amount = periodic_rule.rate
+ quota = periodic_rule.quota
+ else:
+ amount = periodic_rule.quota
+ quota = periodic_rule.quota
+
+ vals = {
+ 'name': periodic_rule.name,
+ 'contract_id': periodic_rule.contract_id.id,
+ 'employee_id': periodic_rule.employee_id.name,
+ 'date_start': periodic_rule.date_start,
+ 'date_end': periodic_rule.date_end,
+ 'amount_per_month': periodic_rule.amount_per_month,
+ 'rate': periodic_rule.rate,
+ 'total_amount': periodic_rule.total_amount,
+ 'amount_per_month':amount,
+ 'quota': quota,
+ 'accumulated_ammount': periodic_rule.quota,
+ 'percentage':periodic_rule.percentage,
+ 'id': periodic_rule.id,
+ 'category': periodic_rule.category,
+ }
+ else:
+ if periodic_rule.percentage is True:
+ amount = periodic_rule.rate
+ quota = periodic_rule.quota
+ else:
+ amount = periodic_rule.quota
+ quota = periodic_rule.quota
+
+ vals = {
+ 'name': periodic_rule.name,
+ 'contract_id': periodic_rule.contract_id.id,
+ 'employee_id': periodic_rule.employee_id.name,
+ 'date_start': periodic_rule.date_start,
+ 'date_end': periodic_rule.date_end,
+ 'amount_per_month': periodic_rule.amount_per_month,
+ 'rate': periodic_rule.rate,
+ 'total_amount': periodic_rule.total_amount,
+ 'amount_per_month':amount,
+ 'quota': quota,
+ 'accumulated_ammount': periodic_rule.quota,
+ 'percentage':periodic_rule.percentage,
+ 'id': periodic_rule.id,
+ 'category': periodic_rule.category,
+ }
+
+ lines.append(copy(vals))
+ return lines
+
+ def get_periodic_rule_type_report(self,data):
+ lines = []
+ vals = {}
+
+ periodic_rules_ids = self.pool.get('hr.payroll.periodic.rule').search(self.cr, self.uid, [('type_id','=',data['form']['type_id'][0])])
+ if periodic_rules_ids:
+ for periodic_rule in self.pool.get('hr.payroll.periodic.rule').browse(self.cr, self.uid, periodic_rules_ids, context = None):
+ if data['form']['type_filter'] == 'date':
+ if periodic_rule.date_start >= data['form']['date_start'] and periodic_rule.date_end <= data['form']['date_end']:
+ if periodic_rule.percentage is True:
+ amount = periodic_rule.rate
+ quota = periodic_rule.quota
+ else:
+ amount = periodic_rule.quota
+ quota = periodic_rule.quota
+
+ vals = {
+ 'name': periodic_rule.name,
+ 'contract_id': periodic_rule.contract_id.id,
+ 'employee_id': periodic_rule.employee_id.name,
+ 'date_start': periodic_rule.date_start,
+ 'date_end': periodic_rule.date_end,
+ 'amount_per_month': periodic_rule.amount_per_month,
+ 'rate': periodic_rule.rate,
+ 'total_amount': periodic_rule.total_amount,
+ 'amount_per_month':amount,
+ 'quota': quota,
+ 'accumulated_ammount': periodic_rule.quota,
+ 'percentage':periodic_rule.percentage,
+ 'id': periodic_rule.id,
+ 'category': periodic_rule.category,
+ }
+ else:
+ if periodic_rule.percentage is True:
+ amount = periodic_rule.rate
+ quota = periodic_rule.quota
+ else:
+ amount = periodic_rule.quota
+ quota = periodic_rule.quota
+
+ vals = {
+ 'name': periodic_rule.name,
+ 'contract_id': periodic_rule.contract_id.id,
+ 'employee_id': periodic_rule.employee_id.name,
+ 'date_start': periodic_rule.date_start,
+ 'date_end': periodic_rule.date_end,
+ 'amount_per_month': periodic_rule.amount_per_month,
+ 'rate': periodic_rule.rate,
+ 'total_amount': periodic_rule.total_amount,
+ 'amount_per_month':amount,
+ 'quota': quota,
+ 'accumulated_ammount': periodic_rule.quota,
+ 'percentage':periodic_rule.percentage,
+ 'id': periodic_rule.id,
+ 'category': periodic_rule.category,
+ }
+
+ lines.append(copy(vals))
+ return lines
+
+ def get_total_periodic_rules(self,periodic_rule, periodic_rule_lines):
+ vals = {
+ 'accumulated_amount':0.0,
+ 'total_amount': 0.0,
+ 'pendient_ammount':0.0,
+ }
+ accum_amm = 0.0
+ total_amm = 0.0
+ pendient_amm = 0.0
+
+ if len(periodic_rule) > 0:
+ #lines
+ for line in periodic_rule_lines:
+ if line['cancel']:
+ accum_amm += float(line['total_amount'])
+ if len(periodic_rule) > 0:
+ #periodic_rule
+ for periodic in periodic_rule:
+ total_amm += float(periodic['total_amount'])
+
+ vals['accumulated_amount'] = float(accum_amm)
+ vals['total_amount'] = float(total_amm)
+ vals['pendient_amm'] = float(total_amm - accum_amm)
+
+ return vals
+
+ def get_lines(self, data):
+ lines = []
+
+ if data['form']['type_report'] == 'category':
+ lines = self.get_periodic_rule_category_report(data)
+
+ if data['form']['type_report'] == 'contract':
+ lines = self.get_periodic_rule_contract_report(data)
+
+ if data['form']['type_report'] == 'periodic_rule':
+ lines = self.get_periodic_rule_type_report(data)
+
+ return lines
+
+ #####################################################################################################
+
+
+#the parameters are the report name and module name
+report_sxw.report_sxw( 'report.hr_payroll_periodic_rule_report_webkit',
+ 'hr.payroll.periodic.rule',
+ 'hr_payroll_periodic_rule/report/hr_payroll_periodic_rule.mako',
+ parser = hr_payroll_periodic_rule_report_parser,
+ header='internal')
+
+#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'hr_payroll_periodic_rule/report/report.xml'
--- hr_payroll_periodic_rule/report/report.xml 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/report/report.xml 2012-07-24 22:01:20 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <record id="hr_payroll_periodic_rule_report" model="ir.actions.report.xml">
+ <field name="report_type">webkit</field>
+ <field name="report_name">hr_payroll_periodic_rule_report_webkit</field>
+ <field eval="[(6,0,[])]" name="groups_id"/>
+ <field eval="0" name="multi"/>
+ <field eval="0" name="auto"/>
+ <field eval="1" name="header"/>
+ <field name="model">hr.payroll.periodic.rule</field>
+ <field name="type">ir.actions.report.xml</field>
+ <field name="name">Periodic Rule Report</field>
+ <field name="report_rml">hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.mako</field>
+ <field name="report_file">hr_payroll_periodic_rule/report/hr_payroll_periodic_rule_report.mako</field>
+ </record>
+
+ </data>
+</openerp>
=== added file 'hr_payroll_periodic_rule/report_menus.xml'
--- hr_payroll_periodic_rule/report_menus.xml 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/report_menus.xml 2012-07-24 22:01:20 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+
+ <!-- <menuitem icon="STOCK_PRINT" name="Partner Ledger"
+ parent="account.next_id_22" action="action_account_partners_ledger_menu_webkit"
+ groups="account.group_account_manager,account.group_account_user" id="account.menu_account_partner_ledger"/>
+
+ <menuitem icon="STOCK_PRINT" name="Open Invoices"
+ parent="account.next_id_22" action="action_account_open_invoices_menu_webkit"
+ groups="account.group_account_manager,account.group_account_user" id="menu_account_open_invoices"/> -->
+
+ <menuitem icon="STOCK_PRINT" name="Periodic Rules Report"
+ parent="menu_hr_root_periodic_rule" action="action_periodic_rule_menu_webkit" id="menu_periodic_rule_menu_webkit"/>
+
+ </data>
+</openerp>
+
=== added directory 'hr_payroll_periodic_rule/wizard'
=== added file 'hr_payroll_periodic_rule/wizard/__init__.py'
--- hr_payroll_periodic_rule/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/wizard/__init__.py 2012-07-24 22:01:20 +0000
@@ -0,0 +1,21 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi. Copyright Camptocamp SA
+#
+# 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 hr_payroll_periodic_rule_wizard
=== added file 'hr_payroll_periodic_rule/wizard/hr_payroll_periodic_rule_wizard.py'
--- hr_payroll_periodic_rule/wizard/hr_payroll_periodic_rule_wizard.py 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/wizard/hr_payroll_periodic_rule_wizard.py 2012-07-24 22:01:20 +0000
@@ -0,0 +1,73 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# __openerp__.py
+# hr_payroll_periodic_rule
+# First author: Ronald Rubí Chacón <ronald.rubi@xxxxxxxxxxxxxxx> (ClearCorp S.A.)
+# Second author: Diana Rodríguez Martínez <diana.rodriguez@xxxxxxxxxxxxxxx> (Clearcorp S.A)
+# Copyright (c) 2010-TODAY ClearCorp S.A. (http://clearcorp.co.cr). All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are those of the
+# authors and should not be interpreted as representing official policies, either expressed
+# or implied, of ClearCorp S.A..
+#
+#############################################################################
+
+from osv import osv, fields
+from pprint import PrettyPrinter
+
+class hr_payroll_periodic_rule_wizard( osv.osv_memory ):
+ _name = "hr.payroll.periodic.rule.wizard"
+ _description = 'Periodic Rule wizard report'
+ _columns = {
+ 'contract_id': fields.many2one( 'hr.contract', 'Contract' ),
+ 'category': fields.selection( [( 'saving', 'Saving' ), ( 'loan', 'Loan' ), ( 'embargo', 'Embargo' )], 'Category' ),
+ 'date_start': fields.date( 'Start date' ),
+ 'date_end': fields.date( 'End date' ),
+ 'type_id':fields.many2one( 'hr.payroll.periodic.rule.type', 'Periodic rule type', reandonly = False ),
+ 'type_report': fields.selection([('category', 'Category'), ('contract','Contract'), ('periodic_rule','Periodic rule type')], 'Report type', required=True, readonly=False),
+ 'detail': fields.boolean('Show detail'),
+ 'type_filter': fields.selection([('date','Date')], 'Filter type'),
+ }
+
+ def pre_print_report(self, cr, uid, ids, data, context=None):
+ data = {'form': {} }
+
+ if context is None:
+ context = {}
+ vals = self.read(cr, uid, ids, [], context=context)[0]
+ data['form'].update(vals)
+ return data
+
+ def print_report (self,cr,uid,ids,data,context=None):
+ if context is None:
+ context = {}
+ # we update form with display account value
+ data = self.pre_print_report(cr, uid, ids, data, context=context)
+ return {
+ 'type':'ir.actions.report.xml',
+ 'report_name':'hr_payroll_periodic_rule_report_webkit',
+ 'datas': data,
+ }
+
+hr_payroll_periodic_rule_wizard()
=== added file 'hr_payroll_periodic_rule/wizard/hr_payroll_periodic_rule_wizard_view.xml'
--- hr_payroll_periodic_rule/wizard/hr_payroll_periodic_rule_wizard_view.xml 1970-01-01 00:00:00 +0000
+++ hr_payroll_periodic_rule/wizard/hr_payroll_periodic_rule_wizard_view.xml 2012-07-24 22:01:20 +0000
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data>
+ <record id="periodic_rule_view_webkit" model="ir.ui.view">
+ <field name="name">Periodic Rules</field>
+ <field name="model">hr.payroll.periodic.rule.wizard</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Periodic Rule Report">
+ <label nolabel="1" string=""/>
+ <newline/>
+ <group colspan="4">
+ <field name="type_report"></field>
+ <field name="contract_id" attrs="{'invisible':[('type_report', '!=', 'contract')], 'required': [('type_report','=','contract')]}"/>
+ <field name="category" attrs="{'invisible':[('type_report', '!=', 'category'),('type_report', '!=', 'contract')],'required': [('type_report','=','category')]}" />
+ <field name="detail" attrs="{'invisible':[('type_report', '!=', 'contract')], }" />
+ <field name="type_id" attrs="{'invisible':[('type_report', '!=', 'periodic_rule')], 'required': [('type_report','=','periodic_rule')]}"/>
+ </group>
+ <separator colspan = "4" string=""/>
+ <notebook colspan = "4">
+ <page string = "Filters">
+ <field name="type_filter"></field>
+ <field name="date_start" attrs="{'readonly':[('type_filter','!=','date')]}" colspan="4"></field>
+ <field name="date_end" attrs="{'readonly':[('type_filter','!=','date')]}" colspan="4"></field>
+ </page>
+ </notebook>
+ <group colspan="4">
+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+ <button name="print_report" string="Print" type="object" icon="gtk-print" default_focus="1"/>
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_periodic_rule_menu_webkit" model="ir.actions.act_window">
+ <field name="name">Action Periodic Rules</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">hr.payroll.periodic.rule.wizard</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="periodic_rule_view_webkit"/>
+ <field name="target">new</field>
+ </record>
+ </data>
+</openerp>