Merge lp:~inddiana/sisb/sisb_crear_funcion_fecha_inicio_rel_lab_nomina into lp:sisb

Proposed by [SISB] Aryrosa Fuentes
Status: Merged
Merged at revision: 984
Proposed branch: lp:~inddiana/sisb/sisb_crear_funcion_fecha_inicio_rel_lab_nomina
Merge into: lp:sisb
Diff against target: 66 lines (+56/-0)
1 file modified
sisb_nomina/hr_payroll.py (+56/-0)
To merge this branch: bzr merge lp:~inddiana/sisb/sisb_crear_funcion_fecha_inicio_rel_lab_nomina
Reviewer Review Type Date Requested Status
Juan Lugo Pending
Review via email: mp+337281@code.launchpad.net

Description of the change

[ADD] Se agrega funcion en postgres para calcular la fecha de inicio de la relacion laboral del empleado.

To post a comment you must log in.
984. By [SISB] Aryrosa Fuentes

[ADD] Se agrega funcion en postgres para calcular la fecha de inicio de la relacion laboral del empleado.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sisb_nomina/hr_payroll.py'
2--- sisb_nomina/hr_payroll.py 2017-01-23 15:15:49 +0000
3+++ sisb_nomina/hr_payroll.py 2018-02-07 15:35:56 +0000
4@@ -258,6 +258,62 @@
5 _defaults = {
6 'schedule_pay': 'monthly',
7 }
8+
9+
10+ def _auto_init(self, cursor, context=None):
11+ res = super(hr_contract, self)._auto_init(cursor, context=context)
12+
13+
14+ cursor.execute("""
15+ -- Function: date_start_rel_laboral(integer)
16+ DROP FUNCTION IF EXISTS date_start_rel_laboral(integer);
17+
18+ CREATE OR REPLACE FUNCTION date_start_rel_laboral(p_employee_id integer)
19+ RETURNS date AS
20+ $BODY$
21+ --RETURN current_date;
22+ DECLARE
23+ contrato RECORD;
24+ v_contract_id INTEGER;
25+ v_date_start_up DATE;
26+ v_date_start_dia_ant DATE;
27+ BEGIN
28+
29+ EXECUTE 'select hc.id, hc.date_start
30+ from hr_contract hc
31+ where hc.employee_id = $1
32+ order by hc.date_start desc
33+ LIMIT 1'
34+ INTO v_contract_id, v_date_start_up
35+ USING p_employee_id;
36+
37+ IF (v_contract_id IS NOT NULL) THEN
38+ FOR contrato IN select hc.employee_id, hc.date_start, hc.date_end
39+ from hr_contract hc
40+ where hc.employee_id = p_employee_id and id != v_contract_id
41+ order by hc.date_start desc
42+ LOOP
43+ v_date_start_dia_ant := v_date_start_up - 1;
44+ IF (v_date_start_dia_ant = contrato.date_end) THEN
45+ v_date_start_up := contrato.date_start;
46+ ELSE
47+ RETURN v_date_start_up;
48+ END IF;
49+ END LOOP;
50+ RETURN v_date_start_up;
51+ ELSE
52+ RETURN now();
53+ END IF;
54+
55+ END;
56+
57+ $BODY$
58+ LANGUAGE plpgsql VOLATILE
59+ COST 100;
60+ ALTER FUNCTION date_start_rel_laboral(integer)
61+ OWNER TO oerp;
62+ """)
63+ return res
64
65 def create(self, cr, uid, vals, context=None):
66 if context is None:

Subscribers

People subscribed via source and target branches