Vous êtes sur la page 1sur 432

AIM

BR.100 MANUAL DE SETUP ANEXA 1

SC COMPLEXUL ENERGETIC ROVINARI SA

Sistem informatic de management


Resurse Umane si Salarizare

Edit Formula
Cuprins

Edit Formula 1
PREZENTA_SAPTAMANA_4 5
ACTUALIZARI_RECURENTE 19
ADAOSURI_OCAZIONALE 19
AJUTOARE 22
AJUTOARE 23
AJUTOR_DECES_BASS 24
AJUTOR_DECES_FOND_SALARII 25
ALTE_RETINERI 25
AVANSURI 26
AVANSURI 26
AVANS_CHENZINAL 27
AVANS_CO_1 29
AVANS_DIN_SALARIU 29
AVANTAJE 30
AVANTAJE 31
BAZA_CAS_ANGAJAT 31
BAZA_SANATATE_ANGAJAT 33
BAZA_SANATATE_ANGAJAT 34
BAZA_SOMAJ_ANGAJAT 36
BAZA_SOMAJ_ANGAJAT 42
CALCUL_AVANS 47
CALCUL_CM 48
CALCUL_CM 48
CALCUL_FOAIE_PREZENTA 49
CALCUL_LUNA 49
CALCUL_SALARII 51
CALC_GROSSUP_PAY_VALUE 52
CAR 52
CAR_TOTAL 54
CAS_ANGAJAT 55
CAS_ANGAJATOR 56
CAS_ANGAJAT_DECLARATIE 61
CCP_INDEMNIZATIE 66
CHECK_RATE_TYPE 68
CHIRIE_1 68
CHIRII 69
CM 70
CM_08 99
CM_CFP 101
CM_COMPENSATIE 107
CM_INCEPUT 108
CM_INDEMNIZATIE 112
CM_INDEMNIZATIE 113
CM_LUNA 114
CM_SANATATE_ANGAJATOR 144
CM_SPITALIZARE 145
CM_SUSPENDARE_CONTRACT 147
CM_TIMP 152
CM_VENITURI 153
CM_VENITURI_LUNA 156
CM_XX 157
CM_ZILE_CONTRIBUTIVE 159
CM_ZILE_CONTRIBUTIVE_LUNA 162
CONCEDII 163
CONCEDIU_CU_PLATA 164
CONCEDIU_FARA_PLATA_1 169
CONCEDIU_ODIHNA 174
CONDITII_DE_MUNCA 179
CONTA 180
CORECTII 180
CORECTII 181
COTA_CARBUNE_RETINERE 182
COTIZATIE_SINDICAT 183
COTIZATIE_SINDICAT_RETINERE 184
CO_DIFERENTE 185
DEDUCERE_PERSONALA_1 186
DEFAULT_GROSSUP 189
DELEGATIE 191
EVENIMENTE_FAMILIALE 194
EV_INDEMNIZATIE 198
EXAMPLE_BIS_OT_BAND1 200
FOAIE_PREZENTA 201
FOND_CARTE_MUNCA 201
GARANTIE 202
GARANTII 203
GRAFIC_CHENZINA_I 204
GRAFIC_LUNA 208
GRAFIC_LUNA_CORECTII 212
IMPOZIT_CORECTII 235
IMPUTATIE_RETINERE_1 236
IMPUTATII 238
INDEMNIZATIE_CO 238
INDEMNIZATIE_INVALIDITATE 241
INDEMNIZATIE_PENSIE 243
INDEMNIZATII 244
IND_CA 245
NI_VALIDATION 246
ONCE_EACH_PERIOD 248
ORE_IN_CONDITII_DE_MUNCA 248
PARTICIPARE_PROFIT 249
PENSIE_ALIMENTARA 250
PENSIE_ALIMENTARA_1 251
POPRIRE_AVANS_1 253
POPRIRE_RATE 254
POPRIRE_RATE_LUNA 255
POPRIRE_RETINERE_1 255
POPRIRE_RETINERE_2 257
POPRIRI 259
PREAVIZ 259
PREAVIZ_INDEMNIZATIE 263
PREZENTA_CHENZINA_I 264
PREZENTA_LUNA 265
PREZENTA_SAPTAMANA_1 267
PREZENTA_SAPTAMANA_2 280
PREZENTA_SAPTAMANA_3 293
PREZENTA_SAPTAMANA_5 306
PRIMA 312
PRIMA_BRUTA 313
PRIMA_NETA 319
PRIME 323
PROFIT 324
RATA_1 324
RATE 325
REST_PLATA_1 326
REST_PLATA_2 327
RETINERE_AVANS 328
RETINERI 329
SALARII 330
SALARIU_BAZA 331
SALARIU_BAZA_ANTERIOR 333
SALARIU_BAZA_ORAR 335
SALARIU_BAZA_REALIZAT 336
SALARIU_NET 338
SALARIU_NET_TOTAL 341
SANATATE_ANGAJAT 342
SANATATE_ANGAJATOR 343
SOMAJ_ANGAJATOR 345
SOMAJ_ANGAJAT_CORECTII 350
SPOR 350
SPORT_1 353
SPORURI 354
SPORURI_NEGOCIATE 355
SPORURI_REALIZATE 359
SPOR_CASIER 364
SPOR_CASIER_NEGOCIAT 364
SPOR_CASIER_REALIZAT 364
SPOR_NECONCURENTA_REALIZAT 365
SPOR_TIMP_SUPLIMENTAR_NEGOCIAT 366
SPOR_TIMP_SUPLIMENTAR_REALIZAT 366
STIMULENTE 367
SUSPENDARE_CONTRACT 368
TICHETE_DE_MASA 371
TIMP_LUCRAT 372
TIMP_NELUCRAT 374
TIMP_SUPLIMENTAR 378
TN_LUNA 382
TOTAL_BRUT 405
TOTAL_BRUT 407
TOTAL_RETINERI 410
VECHIME_CURENTA 411
VENITURI_ANTERIOARE_CO 417
VENITURI_CD 418
VENITURI_DIN_SALARII 419
VENITURI_NEIMPOZABILE 422
VENIT_BRUT_INFORMATIV 422
VENIT_LUNAR_IMPOZABIL 425
VENIT_NET 427
ZILE_LUCRATOARE 430
PREZENTA_SAPTAMANA_4

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREZENTA_SAPTAMANA_4 */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* Liber zi [nr] din Grafic luna corectii */


default for LIBER_ZI_22_ASG_RUN is 0
default for LIBER_ZI_23_ASG_RUN is 0
default for LIBER_ZI_24_ASG_RUN is 0
default for LIBER_ZI_25_ASG_RUN is 0
default for LIBER_ZI_26_ASG_RUN is 0
default for LIBER_ZI_27_ASG_RUN is 0
default for LIBER_ZI_28_ASG_RUN is 0

/* [TN] zi [nr]*/
default for CP_ZI_22_ASG_RUN is 0
default for CP_ZI_23_ASG_RUN is 0
default for CP_ZI_24_ASG_RUN is 0
default for CP_ZI_25_ASG_RUN is 0
default for CP_ZI_26_ASG_RUN is 0
default for CP_ZI_27_ASG_RUN is 0
default for CP_ZI_28_ASG_RUN is 0

default for FP_ZI_22_ASG_RUN is 0


default for FP_ZI_23_ASG_RUN is 0
default for FP_ZI_24_ASG_RUN is 0
default for FP_ZI_25_ASG_RUN is 0
default for FP_ZI_26_ASG_RUN is 0
default for FP_ZI_27_ASG_RUN is 0
default for FP_ZI_28_ASG_RUN is 0

default for EV_ZI_22_ASG_RUN is 0


default for EV_ZI_23_ASG_RUN is 0
default for EV_ZI_24_ASG_RUN is 0
default for EV_ZI_25_ASG_RUN is 0
default for EV_ZI_26_ASG_RUN is 0
default for EV_ZI_27_ASG_RUN is 0
default for EV_ZI_28_ASG_RUN is 0
default for CO_ZI_22_ASG_RUN is 0
default for CO_ZI_23_ASG_RUN is 0
default for CO_ZI_24_ASG_RUN is 0
default for CO_ZI_25_ASG_RUN is 0
default for CO_ZI_26_ASG_RUN is 0
default for CO_ZI_27_ASG_RUN is 0
default for CO_ZI_28_ASG_RUN is 0

default for CM_ZI_22_ASG_RUN is 0


default for CM_ZI_23_ASG_RUN is 0
default for CM_ZI_24_ASG_RUN is 0
default for CM_ZI_25_ASG_RUN is 0
default for CM_ZI_26_ASG_RUN is 0
default for CM_ZI_27_ASG_RUN is 0
default for CM_ZI_28_ASG_RUN is 0

default for P_ZI_22_ASG_RUN is 0


default for P_ZI_23_ASG_RUN is 0
default for P_ZI_24_ASG_RUN is 0
default for P_ZI_25_ASG_RUN is 0
default for P_ZI_26_ASG_RUN is 0
default for P_ZI_27_ASG_RUN is 0
default for P_ZI_28_ASG_RUN is 0

default for AN_ZI_22_ASG_RUN is 0


default for AN_ZI_23_ASG_RUN is 0
default for AN_ZI_24_ASG_RUN is 0
default for AN_ZI_25_ASG_RUN is 0
default for AN_ZI_26_ASG_RUN is 0
default for AN_ZI_27_ASG_RUN is 0
default for AN_ZI_28_ASG_RUN is 0

default for SC_ZI_22_ASG_RUN is 0


default for SC_ZI_23_ASG_RUN is 0
default for SC_ZI_24_ASG_RUN is 0
default for SC_ZI_25_ASG_RUN is 0
default for SC_ZI_26_ASG_RUN is 0
default for SC_ZI_27_ASG_RUN is 0
default for SC_ZI_28_ASG_RUN is 0

/* TN Zi [nr] */
default for TN_ZI_22_ASG_RUN is 0
default for TN_ZI_23_ASG_RUN is 0
default for TN_ZI_24_ASG_RUN is 0
default for TN_ZI_25_ASG_RUN is 0
default for TN_ZI_26_ASG_RUN is 0
default for TN_ZI_27_ASG_RUN is 0
default for TN_ZI_28_ASG_RUN is 0
/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_nr_ore = v_durata_muncii
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* zi 22 */
if (v_nr_ore < TN_ZI_22_ASG_RUN) or (TN_ZI_22_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 22 TN = ' + to_text(TN_ZI_22_ASG_RUN)
return v_m1)
/* zi 23 */
if (v_nr_ore < TN_ZI_23_ASG_RUN) or (TN_ZI_23_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 23 TN = ' + to_text(TN_ZI_23_ASG_RUN)
return v_m1)
/* zi 24 */
if (v_nr_ore < TN_ZI_24_ASG_RUN) or (TN_ZI_24_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 24 TN = ' + to_text(TN_ZI_24_ASG_RUN)
return v_m1)
/* zi 25 */
if (v_nr_ore < TN_ZI_25_ASG_RUN) or (TN_ZI_25_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 25 TN = ' + to_text(TN_ZI_25_ASG_RUN)
return v_m1)
/* zi 26 */
if (v_nr_ore < TN_ZI_26_ASG_RUN) or (TN_ZI_26_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 26 TN = ' + to_text(TN_ZI_26_ASG_RUN)
return v_m1)
/* zi 27 */
if (v_nr_ore < TN_ZI_27_ASG_RUN) or (TN_ZI_27_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 27 TN = ' + to_text(TN_ZI_27_ASG_RUN)
return v_m1)
/* zi 28 */
if (v_nr_ore < TN_ZI_28_ASG_RUN) or (TN_ZI_28_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 28 TN = ' + to_text(TN_ZI_28_ASG_RUN)
return v_m1)
/* ---------------------------------------------------------------------------------------
End: Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Prezenta
--------------------------------------------------------------------------------------- */
/* zi 22
------------------------------------------------------------------------*/
v_zi = to_date('22-' + to_text(PAY_PROC_PERIOD_START_DATE, 'MON') + '-' +
to_text(PAY_PROC_PERIOD_START_DATE, 'YYYY'))
v_p_22 = ' '

/* este in luna curenta */


if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_22 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_22_ASG_RUN > 0) then
if (LIBER_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = ' '
else v_p_22 = to_text(v_nr_ore - LIBER_ZI_22_ASG_RUN)
if (CP_ZI_22_ASG_RUN > 0) then
if (CP_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'CP'
else v_p_22 = to_text(v_nr_ore - CP_ZI_22_ASG_RUN)
if (FP_ZI_22_ASG_RUN > 0) then
if (FP_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'FP'
else v_p_22 = to_text(v_nr_ore - FP_ZI_22_ASG_RUN)
if (EV_ZI_22_ASG_RUN > 0) then
if (EV_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'EV'
else v_p_22 = to_text(v_nr_ore - EV_ZI_22_ASG_RUN)
if (CO_ZI_22_ASG_RUN > 0) then
if (CO_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'CO'
else v_p_22 = to_text(v_nr_ore - CO_ZI_22_ASG_RUN)
if (CM_ZI_22_ASG_RUN > 0) then
if (CM_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'CM'
else v_p_22 = to_text(v_nr_ore - CM_ZI_22_ASG_RUN)
if (P_ZI_22_ASG_RUN > 0) then
if (P_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'P'
else v_p_22 = to_text(v_nr_ore - P_ZI_22_ASG_RUN)
if (SC_ZI_22_ASG_RUN > 0) then
if (SC_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'SC'
else v_p_22 = to_text(v_nr_ore - SC_ZI_22_ASG_RUN)
if (AN_ZI_22_ASG_RUN > 0) then
if (AN_ZI_22_ASG_RUN = v_nr_ore)
then v_p_22 = 'AN'
else v_p_22 = to_text(v_nr_ore - AN_ZI_22_ASG_RUN)
)

/* zi 23
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_23 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_23 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_23_ASG_RUN > 0) then
if (LIBER_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = ' '
else v_p_23 = to_text(v_nr_ore - LIBER_ZI_23_ASG_RUN)
if (CP_ZI_23_ASG_RUN > 0) then
if (CP_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'CP'
else v_p_23 = to_text(v_nr_ore - CP_ZI_23_ASG_RUN)
if (FP_ZI_23_ASG_RUN > 0) then
if (FP_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'FP'
else v_p_23 = to_text(v_nr_ore - FP_ZI_23_ASG_RUN)
if (EV_ZI_23_ASG_RUN > 0) then
if (EV_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'EV'
else v_p_23 = to_text(v_nr_ore - EV_ZI_23_ASG_RUN)
if (CO_ZI_23_ASG_RUN > 0) then
if (CO_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'CO'
else v_p_23 = to_text(v_nr_ore - CO_ZI_23_ASG_RUN)
if (CM_ZI_23_ASG_RUN > 0) then
if (CM_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'CM'
else v_p_23 = to_text(v_nr_ore - CM_ZI_23_ASG_RUN)
if (P_ZI_23_ASG_RUN > 0) then
if (P_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'P'
else v_p_23 = to_text(v_nr_ore - P_ZI_23_ASG_RUN)
if (AN_ZI_23_ASG_RUN > 0) then
if (AN_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'AN'
else v_p_23 = to_text(v_nr_ore - AN_ZI_23_ASG_RUN)
if (SC_ZI_23_ASG_RUN > 0) then
if (SC_ZI_23_ASG_RUN = v_nr_ore)
then v_p_23 = 'SC'
else v_p_23 = to_text(v_nr_ore - SC_ZI_23_ASG_RUN)
)

/* zi 24
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_24 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_24 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_24_ASG_RUN > 0) then
if (LIBER_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = ' '
else v_p_24 = to_text(v_nr_ore - LIBER_ZI_24_ASG_RUN)
if (CP_ZI_24_ASG_RUN > 0) then
if (CP_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'CP'
else v_p_24 = to_text(v_nr_ore - CP_ZI_24_ASG_RUN)
if (FP_ZI_24_ASG_RUN > 0) then
if (FP_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'FP'
else v_p_24 = to_text(v_nr_ore - FP_ZI_24_ASG_RUN)
if (EV_ZI_24_ASG_RUN > 0) then
if (EV_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'EV'
else v_p_24 = to_text(v_nr_ore - EV_ZI_24_ASG_RUN)
if (CO_ZI_24_ASG_RUN > 0) then
if (CO_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'CO'
else v_p_24 = to_text(v_nr_ore - CO_ZI_24_ASG_RUN)
if (CM_ZI_24_ASG_RUN > 0) then
if (CM_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'CM'
else v_p_24 = to_text(v_nr_ore - CM_ZI_24_ASG_RUN)
if (P_ZI_24_ASG_RUN > 0) then
if (P_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'P'
else v_p_24 = to_text(v_nr_ore - P_ZI_24_ASG_RUN)
if (SC_ZI_24_ASG_RUN > 0) then
if (SC_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'SC'
else v_p_24 = to_text(v_nr_ore - SC_ZI_24_ASG_RUN)
if (AN_ZI_24_ASG_RUN > 0) then
if (AN_ZI_24_ASG_RUN = v_nr_ore)
then v_p_24 = 'AN'
else v_p_24 = to_text(v_nr_ore - AN_ZI_24_ASG_RUN)
)

/* zi 25
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_25 = ' '
/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_25 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_25_ASG_RUN > 0) then
if (LIBER_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = ' '
else v_p_25 = to_text(v_nr_ore - LIBER_ZI_25_ASG_RUN)
if (CP_ZI_25_ASG_RUN > 0) then
if (CP_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'CP'
else v_p_25 = to_text(v_nr_ore - CP_ZI_25_ASG_RUN)
if (FP_ZI_25_ASG_RUN > 0) then
if (FP_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'FP'
else v_p_25 = to_text(v_nr_ore - FP_ZI_25_ASG_RUN)
if (EV_ZI_25_ASG_RUN > 0) then
if (EV_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'EV'
else v_p_25 = to_text(v_nr_ore - EV_ZI_25_ASG_RUN)
if (CO_ZI_25_ASG_RUN > 0) then
if (CO_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'CO'
else v_p_25 = to_text(v_nr_ore - CO_ZI_25_ASG_RUN)
if (CM_ZI_25_ASG_RUN > 0) then
if (CM_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'CM'
else v_p_25 = to_text(v_nr_ore - CM_ZI_25_ASG_RUN)
if (P_ZI_25_ASG_RUN > 0) then
if (P_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'P'
else v_p_25 = to_text(v_nr_ore - P_ZI_25_ASG_RUN)
if (AN_ZI_25_ASG_RUN > 0) then
if (AN_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'AN'
else v_p_25 = to_text(v_nr_ore - AN_ZI_25_ASG_RUN)
if (SC_ZI_25_ASG_RUN > 0) then
if (SC_ZI_25_ASG_RUN = v_nr_ore)
then v_p_25 = 'SC'
else v_p_25 = to_text(v_nr_ore - SC_ZI_25_ASG_RUN)
)

/* zi 26
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_26 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z
/* este o zi lucratoare */
if (x>0) then v_p_26 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_26_ASG_RUN > 0) then
if (LIBER_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = ' '
else v_p_26 = to_text(v_nr_ore - LIBER_ZI_26_ASG_RUN)
if (CP_ZI_26_ASG_RUN > 0) then
if (CP_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'CP'
else v_p_26 = to_text(v_nr_ore - CP_ZI_26_ASG_RUN)
if (FP_ZI_26_ASG_RUN > 0) then
if (FP_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'FP'
else v_p_26 = to_text(v_nr_ore - FP_ZI_26_ASG_RUN)
if (EV_ZI_26_ASG_RUN > 0) then
if (EV_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'EV'
else v_p_26 = to_text(v_nr_ore - EV_ZI_26_ASG_RUN)
if (CO_ZI_26_ASG_RUN > 0) then
if (CO_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'CO'
else v_p_26 = to_text(v_nr_ore - CO_ZI_26_ASG_RUN)
if (CM_ZI_26_ASG_RUN > 0) then
if (CM_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'CM'
else v_p_26 = to_text(v_nr_ore - CM_ZI_26_ASG_RUN)
if (P_ZI_26_ASG_RUN > 0) then
if (P_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'P'
else v_p_26 = to_text(v_nr_ore - P_ZI_26_ASG_RUN)
if (SC_ZI_26_ASG_RUN > 0) then
if (SC_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'SC'
else v_p_26 = to_text(v_nr_ore - SC_ZI_26_ASG_RUN)
if (AN_ZI_26_ASG_RUN > 0) then
if (AN_ZI_26_ASG_RUN = v_nr_ore)
then v_p_26 = 'AN'
else v_p_26 = to_text(v_nr_ore - AN_ZI_26_ASG_RUN)
)

/* zi 27
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_27 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)
/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_27 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_27_ASG_RUN > 0) then
if (LIBER_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = ' '
else v_p_27 = to_text(v_nr_ore - LIBER_ZI_27_ASG_RUN)
if (CP_ZI_27_ASG_RUN > 0) then
if (CP_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'CP'
else v_p_27 = to_text(v_nr_ore - CP_ZI_27_ASG_RUN)
if (FP_ZI_27_ASG_RUN > 0) then
if (FP_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'FP'
else v_p_27 = to_text(v_nr_ore - FP_ZI_27_ASG_RUN)
if (EV_ZI_27_ASG_RUN > 0) then
if (EV_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'EV'
else v_p_27 = to_text(v_nr_ore - EV_ZI_27_ASG_RUN)
if (CO_ZI_27_ASG_RUN > 0) then
if (CO_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'CO'
else v_p_27 = to_text(v_nr_ore - CO_ZI_27_ASG_RUN)
if (CM_ZI_27_ASG_RUN > 0) then
if (CM_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'CM'
else v_p_27 = to_text(v_nr_ore - CM_ZI_27_ASG_RUN)
if (P_ZI_27_ASG_RUN > 0) then
if (P_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'P'
else v_p_27 = to_text(v_nr_ore - P_ZI_27_ASG_RUN)
if (AN_ZI_27_ASG_RUN > 0) then
if (AN_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'AN'
else v_p_27 = to_text(v_nr_ore - AN_ZI_27_ASG_RUN)
if (SC_ZI_27_ASG_RUN > 0) then
if (SC_ZI_27_ASG_RUN = v_nr_ore)
then v_p_27 = 'SC'
else v_p_27 = to_text(v_nr_ore - SC_ZI_27_ASG_RUN)
)

/* zi 28
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_28 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_28 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_28_ASG_RUN > 0) then
if (LIBER_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = ' '
else v_p_28 = to_text(v_nr_ore - LIBER_ZI_28_ASG_RUN)
if (CP_ZI_28_ASG_RUN > 0) then
if (CP_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'CP'
else v_p_28 = to_text(v_nr_ore - CP_ZI_28_ASG_RUN)
if (FP_ZI_28_ASG_RUN > 0) then
if (FP_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'FP'
else v_p_28 = to_text(v_nr_ore - FP_ZI_28_ASG_RUN)
if (EV_ZI_28_ASG_RUN > 0) then
if (EV_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'EV'
else v_p_28 = to_text(v_nr_ore - EV_ZI_28_ASG_RUN)
if (CO_ZI_28_ASG_RUN > 0) then
if (CO_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'CO'
else v_p_28 = to_text(v_nr_ore - CO_ZI_28_ASG_RUN)
if (CM_ZI_28_ASG_RUN > 0) then
if (CM_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'CM'
else v_p_28 = to_text(v_nr_ore - CM_ZI_28_ASG_RUN)
if (P_ZI_28_ASG_RUN > 0) then
if (P_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'P'
else v_p_28 = to_text(v_nr_ore - P_ZI_28_ASG_RUN)
if (SC_ZI_28_ASG_RUN > 0) then
if (SC_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'SC'
else v_p_28 = to_text(v_nr_ore - SC_ZI_28_ASG_RUN)
if (AN_ZI_28_ASG_RUN > 0) then
if (AN_ZI_28_ASG_RUN = v_nr_ore)
then v_p_28 = 'AN'
else v_p_28 = to_text(v_nr_ore - AN_ZI_28_ASG_RUN)
)
/* ---------------------------------------------------------------------------------------
End: Prezenta
--------------------------------------------------------------------------------------- */

return
/* Prezenta */
v_p_22,
v_p_23,
v_p_24,
v_p_25,
v_p_26,
v_p_27,
v_p_28

/* End: Formula: PREZENTA_SAPTAMANA_4 */


ACTUALIZARI_RECURENTE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: ACTUALIZARI_RECURENTE */

default for VECHIME_ANI_ASG_RUN is 0


default for VECHIME_LUNI_ASG_RUN is 0
default for VECHIME_ZILE_ASG_RUN is 0

default for CO_SPORURI_ASG_MONTH is 0


default for VENITURI_CO_1_ASG_RUN is 0
default for VENITURI_CO_2_ASG_RUN is 0

v_vechime_ani = VECHIME_ANI_ASG_RUN
v_vechime_luni = VECHIME_LUNI_ASG_RUN
v_vechime_zile = VECHIME_ZILE_ASG_RUN

v_venituri_co_1 = CO_SPORURI_ASG_MONTH
v_venituri_co_2 = VENITURI_CO_1_ASG_RUN
v_venituri_co_3 = VENITURI_CO_2_ASG_RUN

return
/* Vechime curenta */
v_vechime_ani,
v_vechime_luni,
v_vechime_zile,

/* Venituri anterioare CO */
v_venituri_co_1,
v_venituri_co_2,
v_venituri_co_3

/* End: Formula: ACTUALIZARI_RECURENTE */

ADAOSURI_OCAZIONALE

default for PLAFON_VENIT_NEIMPOZABIL is 0


default for SUMA_ACORDATA is 0
default for ACORDAT_IN_AVANS is 'D'
default for ELEMENT_NAME is ' '

inputs are
SUMA_ACORDATA,
ACORDAT_IN_AVANS

if SUMA_ACORDATA was defaulted then


v_suma = PLAFON_VENIT_NEIMPOZABIL
else
v_suma = SUMA_ACORDATA

if ACORDAT_IN_AVANS = 'D' then


(
v_avans = v_suma
v_lansare_avans = ELEMENT_NAME
)

v_suma_neimp = least(SUMA_ACORDATA,PLAFON_VENIT_NEIMPOZABIL)

return
v_suma,
v_suma_neimp,
v_avans,
v_lansare_avans

ADAOS_AJUTOR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: ADAOS_AJUTOR */

default for FEL is ' '


default for SUMA is 0
default for ACORDAT_IN_AVANS is 'D'
default for AVANS is 0
default for Data_plata is '01-FEB-1900' (DATE)
default for IMPOZABIL is 'D'

default for ELEMENT_NAME is ' '


default for PLAFON_VENIT_NEIMPOZABIL is 0
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)
default for SALARIU_BAZA_LUNAR_ASG_RUN is 0
default for SPORURI_NEGOCIATE_PROCENTE_ASG_RUN is 0
default for INDEMNIZATIE_CONDUCERE_ASG_RUN is 0
default for INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN is 0
default for JOB_KF_ALOCATIE_CARBUNE is '0'
default for COST_TONA_CARBUNE is 0
default for ROT is 0

inputs are
FEL,
SUMA,
ACORDAT_IN_AVANS,
AVANS,
Data_plata,
IMPOZABIL

/* --------------------------
Suma
--------------------------- */

v_suma = SUMA
if SUMA was defaulted then v_suma = PLAFON_VENIT_NEIMPOZABIL

/* ----------------------------------------------
50-Ajutor pentru cstoria salariatului
----------------------------------------------- */
if (substr(FEL,1,2) = '50') then
(
v_sp_procente = SPORURI_NEGOCIATE_PROCENTE_ASG_RUN
y = SALARIU_BAZA_LUNAR_ASG_RUN * (1 + v_sp_procente / 100)
+ (INDEMNIZATIE_CONDUCERE_ASG_RUN
+ INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN)
v_suma = round( y, 2)
)

/* ----------------------------------------------
60-Cota carbune
----------------------------------------------- */
if (substr(FEL,1,2) = '60') then
(
v_cota = to_num(JOB_KF_ALOCATIE_CARBUNE)
v_cost = COST_TONA_CARBUNE
v_suma = round(v_cost * v_cota, ROT)
)

/* --------------------------
End: Suma
--------------------------- */

/* --------------------------
avans
----------------------------- */

if ACORDAT_IN_AVANS = 'D' then


(
v_lansare_avans = ELEMENT_NAME
v_data_plata = DATA_PLATA
if DATA_PLATA was defaulted then v_data_plata = PAY_PROC_PERIOD_START_DATE
v_avans = v_suma
if AVANS was not defaulted then v_avans = AVANS
)

/* --------------------------
end: avans
----------------------------- */

/* --------------------------
Proportia impozabila
----------------------------- */
if IMPOZABIL = 'D' then v_suma_imp = v_suma

if IMPOZABIL = 'N' then v_suma_neimp = v_suma

if IMPOZABIL = 'P' then


(
v_suma_neimp = least(v_suma, PLAFON_VENIT_NEIMPOZABIL)
v_suma_imp = greatest(0, v_suma - v_suma_neimp)
)
/* --------------------------
End: Proportia impozabila
----------------------------- */

return
v_suma,
v_suma_neimp,
v_suma_imp,
/* Avans ajutor */
v_avans, /* Conta Acordare avans salarial */ /* Conta Avans salarial */
v_data_plata, /* Conta Acordare avans salarial */
v_lansare_avans

/* End: Formula: ADAOS_AJUTOR */

AJUTOARE

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *


* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: AJUTOARE */

default for AJUTOARE_ASG_MONTH is 0

v_ajutoare = AJUTOARE_ASG_MONTH

if (v_ajutoare <> 0) then v_suma = v_ajutoare

return

v_ajutoare,

/* Conta Ajutoare */

v_suma

/* End: Formula: AJUTOARE */

AJUTOARE

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *


* *

******************************************************************/

/* Formula: AJUTOARE */

default for AJUTOARE_ASG_MONTH is 0

v_ajutoare = AJUTOARE_ASG_MONTH

if (v_ajutoare <> 0) then v_suma = v_ajutoare

return

v_ajutoare,

/* Conta Ajutoare */

v_suma

/* End: Formula: AJUTOARE */

AJUTOR_DECES_BASS

default for SAL_MEDIU_ECONOMIE is 0


default for TIP_AJUTOR is 'A'
default for ACORDAT_IN_AVANS is 'D'
default for ELEMENT_NAME is ' '

inputs are
TIP_AJUTOR,
ACORDAT_IN_AVANS

if (TIP_AJUTOR = 'A') then


v_valoare_ajutor = SAL_MEDIU_ECONOMIE

if (TIP_AJUTOR = 'M') then


v_valoare_ajutor = round(SAL_MEDIU_ECONOMIE/2)

if ACORDAT_IN_AVANS = 'D' then


(
v_avans = v_valoare_ajutor
v_lansare_avans = ELEMENT_NAME
)

return
v_valoare_ajutor,
v_avans,
v_lansare_avans

AJUTOR_DECES_FOND_SALARII

default for SUMA_ACORDATA is 0


default for ACORDAT_IN_AVANS is 'D'
default for ELEMENT_NAME is ' '

inputs are
SUMA_ACORDATA,
ACORDAT_IN_AVANS

v_valoare_ajutor = SUMA_ACORDATA

if ACORDAT_IN_AVANS = 'D' then


(
v_avans = v_valoare_ajutor
v_lansare_avans = ELEMENT_NAME
)

return
v_valoare_ajutor,
v_avans,
v_lansare_avans

ALTE_RETINERI

/********************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: ALTE_RETINERI */

default for ALTE_RETINERI_ASG_MONTH is 0

v_alte_ret = ALTE_RETINERI_ASG_MONTH
if (v_alte_ret <> 0) then v_suma = v_alte_ret

return
v_alte_ret,

/* Conta Alte retineri */


v_suma

/* End: Formula: ALTE_RETINERI */

AVANSURI

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: AVANSURI */

default for AVANSURI_ASG_MONTH is 0

v_avansuri = AVANSURI_ASG_MONTH

return v_avansuri

/* End: Formula: AVANSURI */

AVANSURI

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *


* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: AVANSURI */

default for AVANSURI_ASG_MONTH is 0

v_avansuri = AVANSURI_ASG_MONTH

return v_avansuri

/* End: Formula: AVANSURI */

AVANS_CHENZINAL

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: AVANS_CHENZINAL */

default for PROCENT is 0


default for AVANS is 0
default for DATA_PLATA is '01-FEB-2003' (date)

default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)


default for SALARIU_BAZA_LUNAR_ASG_RUN is 0
default for AVANS_CHENZINAL_CORECTIE_ASG_RUN is 0
default for ZILE_LUCRATOARE_CHENZINA_I_ASG_RUN is 1
default for ZILE_LUCRATE_CHENZINA_I_ASG_RUN is 0 /* Zile calculate */
default for ORE_LUCRATE_CHENZINA_I_ASG_RUN is 0 /* Zile calculate */
default for POPRIRE_AVANS_1_ASG_RUN is 0
default for ELEMENT_NAME is ' '

inputs are
PROCENT,
AVANS,
DATA_PLATA

pontaj = 0
if ZILE_LUCRATOARE_CHENZINA_I_ASG_RUN <> 0 then
pontaj = ZILE_LUCRATE_CHENZINA_I_ASG_RUN / ZILE_LUCRATOARE_CHENZINA_I_ASG_RUN
v_avans = SALARIU_BAZA_LUNAR_ASG_RUN * PROCENT / 100
v_avans = v_avans * pontaj
if AVANS was not defaulted then v_avans = AVANS * pontaj
v_avans = round(v_avans, -1)

/* modificare temporara */
if AVANS_CHENZINAL_CORECTIE_ASG_RUN <> 0 then
v_avans = AVANS_CHENZINAL_CORECTIE_ASG_RUN

v_data_plata = DATA_PLATA
if DATA_PLATA was defaulted then v_data_plata = PAY_PROC_PERIOD_START_DATE

v_suma = round(SALARIU_BAZA_LUNAR_ASG_RUN * PROCENT / 100, -1)


v_m1 = ELEMENT_NAME + ': normal=' + to_text(v_suma)
v_zile = ZILE_LUCRATE_CHENZINA_I_ASG_RUN
v_ore = ORE_LUCRATE_CHENZINA_I_ASG_RUN
v_salariu = SALARIU_BAZA_LUNAR_ASG_RUN

/* -----------------
Retineri
----------------- */
v_retineri = 0
v_de_plata = v_avans - v_retineri

y = least(POPRIRE_AVANS_1_ASG_RUN, v_de_plata)
if y > 0 then v_poprire_platita_1 = y
v_retineri = v_retineri + y

v_de_plata = v_avans - v_retineri


/* -----------------
End: Retineri
----------------- */

return
v_avans, /* PV */ /* Conta Acordare avans salarial */ /* Conta Avans salarial */
v_data_plata, /* Data plata */ /* Conta Acordare avans salarial */
v_m1,
v_suma,
v_zile,
v_ore,
v_salariu,
v_retineri,
v_de_plata,

v_poprire_platita_1 /* Poprire platita 1 */

/* End: Formula: AVANS_CHENZINAL */

AVANS_CO_1
/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: AVANS_CO_1 */

default for AVANS_CO_1_ASG_ITD is 0

default for VENITURI_ANTERIOARE_CO_ASG_RUN is 0


default for SALARIU_NET_ASG_RUN is 0

default for ZILE_RAMASE is 0


default for ZILE_LUNA_CURENTA is 0
default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0

inputs are
ZILE_RAMASE,
ZILE_LUNA_CURENTA

v_sal_n = SALARIU_NET_ASG_RUN
v_z_lucratoare_lu = ZILE_LUCRATOARE_LUNA_ASG_RUN
v_avans_acordat = 0

if ZILE_RAMASE <> ZILE_LUNA_CURENTA


then
v_avans_retinut = round(AVANS_CO_1_ASG_ITD / ZILE_RAMASE * ZILE_LUNA_CURENTA, -1)
else
v_avans_retinut = AVANS_CO_1_ASG_ITD

return
v_avans_acordat,
v_avans_retinut

/* End: Formula: AVANS_CO_1*/

AVANS_DIN_SALARIU

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: AVANS_DIN_SALARIU */

default for SUMA_ACORDATA is 0


default for DATA_PLATA is '01-FEB-2003' (date)

default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)


inputs are
SUMA_ACORDATA,
DATA_PLATA

v_avans = SUMA_ACORDATA
v_data_plata = DATA_PLATA
if DATA_PLATA was defaulted then v_data_plata = PAY_PROC_PERIOD_START_DATE

return
v_avans, /* PV */ /* Conta Acordare avans salarial */ /* Conta Avans salarial */
v_data_plata /* Data plata */ /* Conta Acordare avans salarial */

/* End: Formula: AVANS_DIN_SALARIU */

AVANTAJE

/********************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: AVANTAJE */

default for AVANTAJE_ASG_MONTH is 0

v_avantaje = AVANTAJE_ASG_MONTH

if (v_avantaje <> 0) then v_suma = v_avantaje

return

v_avantaje,

/* Conta Avantaje */

v_suma
/* End: Formula: AVANTAJE */

AVANTAJE

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: AVANTAJE */

default for AVANTAJE_ASG_MONTH is 0

v_avantaje = AVANTAJE_ASG_MONTH

if (v_avantaje <> 0) then v_suma = v_avantaje

return

v_avantaje,

/* Conta Avantaje */

v_suma

/* End: Formula: AVANTAJE */

BAZA_CAS_ANGAJAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: BAZA_CAS_ANGAJAT */

default for BAZA_CAS_ANGAJAT_ASG_MONTH is 0


default for SAL_MEDIU_ECONOMIE is 0
default for NR_SALARII_CAS is 5

default for BAZA_CAS_ANGAJAT_PER_MONTH is 0


default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for ASG_PRIMARY is ' ' /* Yes / No */
default for ELEMENT_NAME is ' '

/* -------------------------------------------------------------------------
Baza CAS angajat
------------------------------------------------------------------------- */
plafon = SAL_MEDIU_ECONOMIE * NR_SALARII_CAS

v_baza_neplafonata = BAZA_CAS_ANGAJAT_ASG_MONTH

v_baza_calcul_cas = BAZA_CAS_ANGAJAT_ASG_MONTH
/* plafonare */
if (plafon < v_baza_calcul_cas) then v_baza_calcul_cas = plafon

/* ----------------
corectie
------------------- */
if ASG_PRIMARY= 'Yes' and MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
(
b_t = BAZA_CAS_ANGAJAT_PER_MONTH
if plafon < b_t then b_t = plafon

b_asg_s = BAZA_CAS_ANGAJAT_PER_MONTH - BAZA_CAS_ANGAJAT_ASG_MONTH


if plafon < b_asg_s then b_asg_s = plafon

b_asg_p_corecta = b_t - b_asg_s


b_asg_p = BAZA_CAS_ANGAJAT_ASG_MONTH
if plafon < b_asg_p then b_asg_p = plafon
b_dif = b_asg_p_corecta - b_asg_p

v_baza_calcul_cas = v_baza_calcul_cas + b_dif


if b_dif <> 0 then v_m1 = ELEMENT_NAME + ': Baza dif=' + to_text(b_dif)
)
/* ----------------
end: corectie
------------------- */
/* -------------------------------------------------------------------------
End: Baza CAS angajat
------------------------------------------------------------------------- */

v_baza_calcul_cas = round(v_baza_calcul_cas)
v_baza_neplafonata = round(v_baza_neplafonata)
return

/* Baza CAS angajat */


v_baza_calcul_cas, /* CAS angajat */
v_baza_neplafonata, /* CAS angajat */

v_m1

/* End: Formula: BAZA_CAS_ANGAJAT */

BAZA_SANATATE_ANGAJAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: BAZA_SANATATE_ANGAJAT (versiunea de la 01 MAY 2005)*/

default for BAZA_SANATATE_ANGAJAT_ASG_MONTH is 0


default for MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for EMP_HIRE_DATE is '01-FEB-2003' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* -------------------------------------------------------------------------
Baza Sanatate angajat
------------------------------------------------------------------------- */
v_baza_calcul_san = BAZA_SANATATE_ANGAJAT_ASG_MONTH

/* -------------------------------------------------------------------------
End: Baza Sanatate angajat
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Declaratie
------------------------------------------------------------------------- */
v_Nr_pers = 1

/* salariat - S; concediu ngrijire copil - CIC; angajat pe baz de convenie civil ? ACC */
/* va trebui tratat CIC */
v_Categorie_asigurat = 'S'

/* personalul care intr n activitate


----------------------------------------*/
v_data_angajarii = MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE was defaulted)
then
v_data_angajarii = EMP_HIRE_DATE
v_Data_intrarii = v_data_angajarii
if (PAY_PROC_PERIOD_START_DATE < v_data_angajarii and
v_data_angajarii <= PAY_PROC_PERIOD_END_DATE)
then
/* angajat in cursul lunii
-------------------------- */
(
v_Intra_in_activitate = 'Y'
)
/* End: personalul care intr n activitate
----------------------------------------------*/

/* personalul care iese din activitate


----------------------------------------*/
v_data_terminarii = MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_terminarii = EMP_TERM_DATE

if (PAY_PROC_PERIOD_START_DATE <= v_data_terminarii and


v_data_terminarii < PAY_PROC_PERIOD_END_DATE)
then
/* plecat in cursul lunii
-------------------------*/
(
v_Iese_din_activitate = 'Y'
v_Data_iesirii = v_data_terminarii
)
/* End: personalul care iese din activitate
----------------------------------------------*/
/* -------------------------------------------------------------------------
End: Declaratie
------------------------------------------------------------------------- */
return
v_baza_calcul_san,

/* Sanatate angajat */
v_Nr_pers,
v_Categorie_asigurat,
v_Intra_in_activitate,
v_Data_intrarii,
v_Iese_din_activitate,
v_Data_iesirii

/* End: Formula: BAZA_SANATATE_ANGAJAT */

BAZA_SANATATE_ANGAJAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: BAZA_SANATATE_ANGAJAT (versiunea de la 01 MAY 2005)*/


default for BAZA_SANATATE_ANGAJAT_ASG_MONTH is 0
default for MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for EMP_HIRE_DATE is '01-FEB-2003' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* -------------------------------------------------------------------------
Baza Sanatate angajat
------------------------------------------------------------------------- */
v_baza_calcul_san = BAZA_SANATATE_ANGAJAT_ASG_MONTH

/* -------------------------------------------------------------------------
End: Baza Sanatate angajat
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Declaratie
------------------------------------------------------------------------- */
v_Nr_pers = 1

/* salariat - S; concediu ngrijire copil - CIC; angajat pe baz de convenie civil ? ACC */
/* va trebui tratat CIC */
v_Categorie_asigurat = 'S'

/* personalul care intr n activitate


----------------------------------------*/
v_data_angajarii = MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE was defaulted)
then
v_data_angajarii = EMP_HIRE_DATE
v_Data_intrarii = v_data_angajarii

if (PAY_PROC_PERIOD_START_DATE < v_data_angajarii and


v_data_angajarii <= PAY_PROC_PERIOD_END_DATE)
then
/* angajat in cursul lunii
-------------------------- */
(
v_Intra_in_activitate = 'Y'
)
/* End: personalul care intr n activitate
----------------------------------------------*/

/* personalul care iese din activitate


----------------------------------------*/
v_data_terminarii = MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_terminarii = EMP_TERM_DATE

if (PAY_PROC_PERIOD_START_DATE <= v_data_terminarii and


v_data_terminarii < PAY_PROC_PERIOD_END_DATE)
then
/* plecat in cursul lunii
-------------------------*/
(
v_Iese_din_activitate = 'Y'
v_Data_iesirii = v_data_terminarii
)
/* End: personalul care iese din activitate
----------------------------------------------*/
/* -------------------------------------------------------------------------
End: Declaratie
------------------------------------------------------------------------- */
return
v_baza_calcul_san,

/* Sanatate angajat */
v_Nr_pers,
v_Categorie_asigurat,
v_Intra_in_activitate,
v_Data_intrarii,
v_Iese_din_activitate,
v_Data_iesirii

/* End: Formula: BAZA_SANATATE_ANGAJAT */

BAZA_SOMAJ_ANGAJAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: BAZA_SOMAJ_ANGAJAT */

default for BAZA_SOMAJ_ANGAJAT_ASG_RUN is 0 /*inlocuieste


SALARIU_BAZA_NEGOCIAT_ASG_RUN*/
default for BAZA_CAS_ANGAJAT_ASG_MONTH is 0
default for CM_INDEMNIZATIE_ASG_MONTH is 0
default for ORE_LUCRATE_LUNA_ASG_RUN is 0
default for PROC_SOMAJ_ASIG is 0
default for ASG_HOURS is 8
default for EMP_HIRE_DATE is '01-FEB-2003' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)
default for ASG_EMPLOYMENT_CATEGORY_CODE is 'FR'
default for MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for SOMAJ_ZILE_SCUTITE_ASG_RUN is 0
default for ORE_CFP_LUNA_ASG_RUN is 0 /* integer */
/*default for SOMAJ_ORE_SCUTITE_ASG_MONTH is 0 Hours in Decimal format (2 places) */
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 1
default for DURATA_NORMALA_TIMP_LUCRU is 8
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2003' (date)

default for PROGRAM_PARTIAL_ASG_RUN is 0


default for NORMA_INTREAGA_ASG_RUN is 8 /* durata normala timp lucru */
default for ELEMENT_NAME is ' '
/* transfer intre subunitati */
default for ASG_DATE_FROM is '01-FEB-1900' (date)
default for ASG_DATE_TO is '01-FEB-4700' (date)
default for ASG_STATUS is ' '
default for ASG_START_DATE is '01-FEB-1900' (date)

If ORE_LUCRATOARE_LUNA_ASG_RUN = 0 Then
( v_ore_lucr_luna = ORE_LUCRATOARE_LUNA_ASG_MONTH )
Else
( v_ore_lucr_luna = ORE_LUCRATOARE_LUNA_ASG_RUN )

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/

v_norma_intreaga = NORMA_INTREAGA_ASG_RUN
if v_norma_intreaga = 0 then v_norma_intreaga = DURATA_NORMALA_TIMP_LUCRU
v_p_part = PROGRAM_PARTIAL_ASG_RUN

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MON-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MON-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MON-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MON-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MON-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MON-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MON-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MON-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MON-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MON-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MON-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MON-YY')

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if ( v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU) then


v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------
Perioada contributiva
------------------------------------------------------------------ */
/* --------------------------------------------------------------------------------------
Program luna
---------------------------------------------------------------------------------------
nr de zile lucratoare din luna
-------------------------------------*/

v_data_angajarii = MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_angajarii = EMP_HIRE_DATE

v_data_terminarii = MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_terminarii = EMP_TERM_DATE

/* transfer intre subunitati */


if MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
(
v_asg_i = ASG_DATE_FROM
if ASG_STATUS = 'Terminate Assignment' then v_asg_i = ASG_START_DATE
v_data_angajarii = greatest(v_data_angajarii, v_asg_i)

v_asg_s = ASG_DATE_TO
if ASG_STATUS = 'Terminate Assignment' then v_asg_s = ADD_DAYS(ASG_DATE_FROM, -1)
v_data_terminarii = least(v_data_terminarii, v_asg_s)
)

v_data_inceput = greatest(v_data_angajarii, PAY_PROC_PERIOD_START_DATE)

v_data_sfarsit = least(v_data_terminarii, PAY_PROC_PERIOD_END_DATE)

v_zile_lucratoare_luna = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)


/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_lucratoare_luna /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_lucratoare_luna = v_z
/* END: nr de zile lucratoare din luna
----------------------------------------------*/

v_ore_lucratoare_luna = v_zile_lucratoare_luna * v_durata_muncii

v_ore_program_luna = v_ore_lucratoare_luna

/* ---------------------------------------------------------------------------------------
End: Program luna
---------------------------------------------------------------------------------------- */

v_ore_contributive =
/* ore program luna */
v_ore_program_luna -
/* suspendare contract
suspendare contract CM*/
(SOMAJ_ZILE_SCUTITE_ASG_RUN * v_durata_muncii) -
/* ore CFP luna */
ORE_CFP_LUNA_ASG_RUN
/*- SOMAJ_ORE_SCUTITE_ASG_MONTH*/

v_zile_suspendate = SOMAJ_ZILE_SCUTITE_ASG_RUN
/* units = Hours
+ SOMAJ_ORE_SCUTITE_ASG_MONTH / v_durata_muncii*/
v_zile_lucrate =
( ORE_LUCRATE_LUNA_ASG_RUN /*- SOMAJ_ORE_SCUTITE_ASG_MONTH*/ ) / v_durata_muncii
/* ------------------------------------------------------------------
End: Perioada contributiva
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Baza calcul
------------------------------------------------------------------ */

if
/* salariat pensionar pe limita de varsta */
MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'P'
/* salariat cetatean strain */
or MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'R'
or MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'N'
then v_baza_somaj = 0

else

v_baza_somaj =
round(BAZA_SOMAJ_ANGAJAT_ASG_RUN * (v_ore_contributive / v_ore_lucr_luna ), 0)

/* nu poate exista contributie fara posibilitatea retinerii acesteia */


if BAZA_CAS_ANGAJAT_ASG_MONTH
+ CM_INDEMNIZATIE_ASG_MONTH = 0 then v_baza_somaj = 0

/* ------------------------------------------------------------------
End: Baza calcul
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
Contributie
------------------------------------------------------------------ */

v_somaj = round(v_baza_somaj * PROC_SOMAJ_ASIG,0)

/* ------------------------------------------------------------------
End: Contributie
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Declaratie
------------------------------------------------------------------ */

/* calculeaza Tip contract


----------------------------------------------- */
/*
Parttime = timp partial
Fulltime = timp normal (norma intreaga)

Regular = durata nedeterminata


Temporary = durata determinata

Parttime-Regular
Parttime-Temporary
Fulltime-Regular
Fulltime-Temporary
*/

v_tip_contract = ' '

/* TC=1 Pentru CIM pe durata nedetrminata:


-cu durata normala a timpului de munca, sau ;
-lucru cu norma intreaga */
if (ASG_EMPLOYMENT_CATEGORY_CODE = 'FR') then
v_tip_contract = '1'

v_m1 = ELEMENT_NAME + ': norma intreaga=' + to_text(v_norma_intreaga) + ' EMP_CAT=' +


ASG_EMPLOYMENT_CATEGORY_CODE

if (ASG_EMPLOYMENT_CATEGORY_CODE = 'PR') then


(
if (v_norma_intreaga = 8) then v_tip_contract = '2'
if (v_norma_intreaga = 7) then v_tip_contract = '3'
if (v_norma_intreaga = 6) then v_tip_contract = '4'
)

if (ASG_EMPLOYMENT_CATEGORY_CODE = 'FT') then


v_tip_contract = '5'

if (ASG_EMPLOYMENT_CATEGORY_CODE = 'PT') then


(
if (v_norma_intreaga = 8) then v_tip_contract = '6'
if (v_norma_intreaga = 7) then v_tip_contract = '7'
if (v_norma_intreaga = 6) then v_tip_contract = '8'
)
if (ASG_EMPLOYMENT_CATEGORY_CODE = 'FRM') then
v_tip_contract = '9'

/* Exceptie
if (v_p_part = 6) then v_tip_contract = '4'

if (v_p_part = 0) then v_tip_contract = '1'


End: Exceptie */

/* End: calculeaza Tip contract */

/* nr ore norma in zi
----------------------------------------------- */
v_nr_ore_norma = v_durata_muncii

/* Exceptie */
if (v_p_part <> 0) then v_nr_ore_norma = v_p_part
/* End: Exceptie */

/* nr_zile_contributive
----------------------------------------------- */
if
(v_durata_muncii > 0)
then
v_nr_zile_contributive = v_ore_contributive / v_durata_muncii
else
v_nr_zile_contributive = 0
/* ------------------------------------------------------------------
End: Declaratie
------------------------------------------------------------------ */

if (v_somaj <> 0) then v_suma = v_somaj

return
/* Somaj angajat */
v_baza_somaj, /* Baza somaj angajat */
v_somaj,
v_tip_contract,
v_nr_ore_norma,
v_nr_zile_contributive,
v_zile_suspendate,
v_zile_lucrate,

/* Conta Somaj angajat */


v_suma,

v_m1

/* End: Formula: BAZA_SOMAJ_ANGAJAT */

BAZA_SOMAJ_ANGAJAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: BAZA_SOMAJ_ANGAJAT */

default for BAZA_SOMAJ_ANGAJAT_ASG_RUN is 0 /*inlocuieste


SALARIU_BAZA_NEGOCIAT_ASG_RUN*/
default for BAZA_CAS_ANGAJAT_ASG_MONTH is 0
default for CM_INDEMNIZATIE_ASG_MONTH is 0
default for ORE_LUCRATE_LUNA_ASG_RUN is 0
default for PROC_SOMAJ_ASIG is 0
default for ASG_HOURS is 8
default for EMP_HIRE_DATE is '01-FEB-2003' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)
default for ASG_EMPLOYMENT_CATEGORY_CODE is 'FR'
default for MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for SOMAJ_ZILE_SCUTITE_ASG_RUN is 0
default for ORE_CFP_LUNA_ASG_RUN is 0 /* integer */
/*default for SOMAJ_ORE_SCUTITE_ASG_MONTH is 0 Hours in Decimal format (2 places) */
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 1
default for DURATA_NORMALA_TIMP_LUCRU is 8
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2003' (date)

default for PROGRAM_PARTIAL_ASG_RUN is 0


default for NORMA_INTREAGA_ASG_RUN is 8 /* durata normala timp lucru */
default for ELEMENT_NAME is ' '
/* transfer intre subunitati */
default for ASG_DATE_FROM is '01-FEB-1900' (date)
default for ASG_DATE_TO is '01-FEB-4700' (date)
default for ASG_STATUS is ' '
default for ASG_START_DATE is '01-FEB-1900' (date)

If ORE_LUCRATOARE_LUNA_ASG_RUN = 0 Then
( v_ore_lucr_luna = ORE_LUCRATOARE_LUNA_ASG_MONTH )
Else
( v_ore_lucr_luna = ORE_LUCRATOARE_LUNA_ASG_RUN )

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/

v_norma_intreaga = NORMA_INTREAGA_ASG_RUN
if v_norma_intreaga = 0 then v_norma_intreaga = DURATA_NORMALA_TIMP_LUCRU
v_p_part = PROGRAM_PARTIAL_ASG_RUN
z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if ( v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU) then


v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------
Perioada contributiva
------------------------------------------------------------------ */
/* --------------------------------------------------------------------------------------
Program luna
---------------------------------------------------------------------------------------
nr de zile lucratoare din luna
-------------------------------------*/

v_data_angajarii = MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_angajarii = EMP_HIRE_DATE

v_data_terminarii = MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_terminarii = EMP_TERM_DATE

/* transfer intre subunitati */


if MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
(
v_asg_i = ASG_DATE_FROM
if ASG_STATUS = 'Terminate Assignment' then v_asg_i = ASG_START_DATE
v_data_angajarii = greatest(v_data_angajarii, v_asg_i)

v_asg_s = ASG_DATE_TO
if ASG_STATUS = 'Terminate Assignment' then v_asg_s = ADD_DAYS(ASG_DATE_FROM, -1)
v_data_terminarii = least(v_data_terminarii, v_asg_s)
)
v_data_inceput = greatest(v_data_angajarii, PAY_PROC_PERIOD_START_DATE)

v_data_sfarsit = least(v_data_terminarii, PAY_PROC_PERIOD_END_DATE)

v_zile_lucratoare_luna = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)


/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_lucratoare_luna /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_lucratoare_luna = v_z

/* END: nr de zile lucratoare din luna


----------------------------------------------*/

v_ore_lucratoare_luna = v_zile_lucratoare_luna * v_durata_muncii

v_ore_program_luna = v_ore_lucratoare_luna

/* ---------------------------------------------------------------------------------------
End: Program luna
---------------------------------------------------------------------------------------- */

v_ore_contributive =
/* ore program luna */
v_ore_program_luna -
/* suspendare contract
suspendare contract CM*/
(SOMAJ_ZILE_SCUTITE_ASG_RUN * v_durata_muncii) -
/* ore CFP luna */
ORE_CFP_LUNA_ASG_RUN
/*- SOMAJ_ORE_SCUTITE_ASG_MONTH*/

v_zile_suspendate = SOMAJ_ZILE_SCUTITE_ASG_RUN
/* units = Hours
+ SOMAJ_ORE_SCUTITE_ASG_MONTH / v_durata_muncii*/
v_zile_lucrate =
( ORE_LUCRATE_LUNA_ASG_RUN /*- SOMAJ_ORE_SCUTITE_ASG_MONTH*/ ) / v_durata_muncii
/* ------------------------------------------------------------------
End: Perioada contributiva
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Baza calcul
------------------------------------------------------------------ */

if
/* salariat pensionar pe limita de varsta */
MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'P'
/* salariat cetatean strain */
or MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'R'
or MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'N'
then v_baza_somaj = 0

else

v_baza_somaj =
round(BAZA_SOMAJ_ANGAJAT_ASG_RUN * (v_ore_contributive / v_ore_lucr_luna ), 0)

/* nu poate exista contributie fara posibilitatea retinerii acesteia */


if BAZA_CAS_ANGAJAT_ASG_MONTH
+ CM_INDEMNIZATIE_ASG_MONTH = 0 then v_baza_somaj = 0

/* ------------------------------------------------------------------
End: Baza calcul
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Contributie
------------------------------------------------------------------ */

v_somaj = round(v_baza_somaj * PROC_SOMAJ_ASIG,0)

/* ------------------------------------------------------------------
End: Contributie
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Declaratie
------------------------------------------------------------------ */

/* calculeaza Tip contract


----------------------------------------------- */
/*
Parttime = timp partial
Fulltime = timp normal (norma intreaga)

Regular = durata nedeterminata


Temporary = durata determinata
Parttime-Regular
Parttime-Temporary
Fulltime-Regular
Fulltime-Temporary
*/

v_tip_contract = ' '

/* TC=1 Pentru CIM pe durata nedetrminata:


-cu durata normala a timpului de munca, sau ;
-lucru cu norma intreaga */
if (ASG_EMPLOYMENT_CATEGORY_CODE = 'FR') then
v_tip_contract = '1'

v_m1 = ELEMENT_NAME + ': norma intreaga=' + to_text(v_norma_intreaga) + ' EMP_CAT=' +


ASG_EMPLOYMENT_CATEGORY_CODE

if (ASG_EMPLOYMENT_CATEGORY_CODE = 'PR') then


(
if (v_norma_intreaga = 8) then v_tip_contract = '2'
if (v_norma_intreaga = 7) then v_tip_contract = '3'
if (v_norma_intreaga = 6) then v_tip_contract = '4'
)

if (ASG_EMPLOYMENT_CATEGORY_CODE = 'FT') then


v_tip_contract = '5'

if (ASG_EMPLOYMENT_CATEGORY_CODE = 'PT') then


(
if (v_norma_intreaga = 8) then v_tip_contract = '6'
if (v_norma_intreaga = 7) then v_tip_contract = '7'
if (v_norma_intreaga = 6) then v_tip_contract = '8'
)
if (ASG_EMPLOYMENT_CATEGORY_CODE = 'FRM') then
v_tip_contract = '9'

/* Exceptie
if (v_p_part = 6) then v_tip_contract = '4'

if (v_p_part = 0) then v_tip_contract = '1'


End: Exceptie */

/* End: calculeaza Tip contract */

/* nr ore norma in zi
----------------------------------------------- */
v_nr_ore_norma = v_durata_muncii

/* Exceptie */
if (v_p_part <> 0) then v_nr_ore_norma = v_p_part
/* End: Exceptie */

/* nr_zile_contributive
----------------------------------------------- */
if
(v_durata_muncii > 0)
then
v_nr_zile_contributive = v_ore_contributive / v_durata_muncii
else
v_nr_zile_contributive = 0
/* ------------------------------------------------------------------
End: Declaratie
------------------------------------------------------------------ */

if (v_somaj <> 0) then v_suma = v_somaj

return
/* Somaj angajat */
v_baza_somaj, /* Baza somaj angajat */
v_somaj,
v_tip_contract,
v_nr_ore_norma,
v_nr_zile_contributive,
v_zile_suspendate,
v_zile_lucrate,

/* Conta Somaj angajat */


v_suma,

v_m1

/* End: Formula: BAZA_SOMAJ_ANGAJAT */

CALCUL_AVANS

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CALCUL_AVANS */

default for PROCESARE is 0


default for ELEMENT_NAME is ' '

v_procesare = 1
v_lansare = ELEMENT_NAME /* lansarea neconditionata a unui element */

return
v_procesare,
v_lansare

/* End: Formula: CALCUL_AVANS */

CALCUL_CM

/* *******************************************************************
* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CALCUL_CM */

default for PROCESARE is 0

v_procesare = 1

return v_procesare

/* End: Formula: CALCUL_CM */

CALCUL_CM

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CALCUL_CM */

default for PROCESARE is 0


v_procesare = 1

return v_procesare

/* End: Formula: CALCUL_CM */

CALCUL_FOAIE_PREZENTA

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CALCUL_FOAIE_PREZENTA */

default for PROCESARE is 0


default for ELEMENT_NAME is ' '

v_procesare = 1
v_lansare = ELEMENT_NAME /* lansarea neconditionata a unui element */

return
v_procesare,
v_lansare

/* End: Formula: CALCUL_FOAIE_PREZENTA */

CALCUL_LUNA

/********************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CALCUL_LUNA */

default for PROCESARE is 0


default for ELEMENT_NAME is ' '

default for AJUTOARE_ASG_MONTH is 0


default for AVANTAJE_ASG_MONTH is 0
default for CONCEDII_ASG_MONTH is 0
default for INDEMNIZATII_ASG_MONTH is 0
default for STIMULENTE_ASG_MONTH is 0
default for SPORURI_ASG_MONTH is 0
default for PRIME_ASG_MONTH is 0
default for CORECTII_ASG_MONTH is 0
default for SALARII_ASG_MONTH is 0
/*default for JOB_KF_DENUMIRE_ENGLEZA_POST is ' '*/
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for ASG_DATE_FROM is '01-FEB-1900' (date)
default for ASG_DATE_TO is '01-FEB-1900' (date)
default for ASG_STATUS is ' '
default for ASG_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)
default for GROUP_KF_TIP_ACTIVITATE is ' '
default for JOB_KF_CONDITII_NORMALE is '0'
default for JOB_KF_CONDITII_DEOSEBITE is '0'

v_procesare = 1
v_lansare = ELEMENT_NAME /* lansarea neconditionata a unui element */

/* ---------------------------------------------------------------------------------------
Lansare conditionata
--------------------------------------------------------------------------------------- */

if (AJUTOARE_ASG_MONTH <> 0) then v_lans_ajutoare = ELEMENT_NAME


if (AVANTAJE_ASG_MONTH <> 0) then v_lans_avantaje = ELEMENT_NAME
if (CONCEDII_ASG_MONTH <> 0) then v_lans_concedii = ELEMENT_NAME
if (INDEMNIZATII_ASG_MONTH <> 0) then v_lans_indemnizatii = ELEMENT_NAME
if (STIMULENTE_ASG_MONTH <> 0) then v_lans_stimulente = ELEMENT_NAME
if (SPORURI_ASG_MONTH <> 0) then v_lans_sporuri = ELEMENT_NAME
if (PRIME_ASG_MONTH <> 0) then v_lans_prime = ELEMENT_NAME
if (CORECTII_ASG_MONTH <> 0) then v_lans_corectii = ELEMENT_NAME
if (SALARII_ASG_MONTH <> 0) then v_lans_salarii = ELEMENT_NAME

/* ---------------------------
Specific implementarii
------------------------------ */

if GROUP_KF_TIP_ACTIVITATE <> 'Z' then v_lansare_timp = ELEMENT_NAME

if JOB_KF_CONDITII_DEOSEBITE <> '0' then v_lans_cond_m = ELEMENT_NAME

/* ---------------------------
Specific implementarii
------------------------------ */

if ((EMP_TERM_DATE was not defaulted and


EMP_TERM_DATE <= PAY_PROC_PERIOD_END_DATE and
EMP_TERM_DATE >= PAY_PROC_PERIOD_START_DATE) or
(MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was not defaulted)) and
NOT (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T') then
v_lansare_co_diferente = ELEMENT_NAME
v_m1 = ELEMENT_NAME
+ ': ASG_DATE_FROM=' + to_text(ASG_DATE_FROM, 'DD-MON-RRRR')
+ ': ASG_DATE_TO=' + to_text(ASG_DATE_TO, 'DD-MON-RRRR')
+ ': ASG_STATUS=' + ASG_STATUS
+ ': ASG_START_DATE=' + to_text(ASG_START_DATE, 'DD-MON-RRRR')

/* ---------------------------------------------------------------------------------------
End: Lansare conditionata
--------------------------------------------------------------------------------------- */

return
v_procesare,
v_lansare,

/* [venituri salariale] */
v_lans_ajutoare,
v_lans_avantaje,
v_lans_concedii,
v_lans_indemnizatii,
v_lans_stimulente,
v_lans_sporuri,
v_lans_prime,
v_lans_salarii,
v_lans_corectii,

/*v_lansare_spor_casier,*/
v_lansare_timp, /* Timp Lucrat */
v_lansare_co_diferente, /* CO diferente */
v_lans_cond_m, /* Conditii de munca */

v_m1

/* End: Formula: CALCUL_LUNA */

CALCUL_SALARII

/*******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CALCUL_SALARII */

default for PROCESARE is 0


default for ELEMENT_NAME is ' '
default for JOB_KF_DENUMIRE_ENGLEZA_POST is ' '
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '

v_procesare = 1
v_lansare = ELEMENT_NAME

/*if JOB_KF_DENUMIRE_ENGLEZA_POST = 'Teller' then


v_lansare_spor_casier = ELEMENT_NAME*/
if
/* salariat cetatean strain */
MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'R' or
MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'N'
then v_m1 = ELEMENT_NAME + ': ' + ' Salariat cetatean strain, nu calculeaza CAS'
else v_lansare_cas_angajat_declaratie = ELEMENT_NAME

return
v_procesare,
v_lansare,

/*v_lansare_spor_casier,*/
v_lansare_cas_angajat_declaratie

/* End: Formula: CALCUL_SALARII */

CALC_GROSSUP_PAY_VALUE

/******************************************************************************
*
* Formula Name : CALC_GROSSUP_PAY_VALUE
*
* Description : Simple formula to calculate the gross pay based on the
* net pay and additional amount.
*
* Change History
* --------------
*
* Who Date Description
* ---------- ---------- --------------------------------------------------
* N.Bristow 24-NOV-99 Created.
*
*****************************************************************************/
inputs are amount(number),
additional_amount (number)
payment_amount = amount + additional_amount
return payment_amount

CAR

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/
/* Formula: CAR */

default for TAXA_INSCRIERE is 0

default for COTIZATIE is 0

default for RATA is 0

default for DOBANDA is 0

default for REST_PLATA_2_ASG_MONTH is 0

inputs are

TAXA_INSCRIERE,

COTIZATIE,

RATA,

DOBANDA

v_disponibil = REST_PLATA_2_ASG_MONTH

v_suma_de_retinut = TAXA_INSCRIERE +

COTIZATIE +

RATA +

DOBANDA

if (v_suma_de_retinut < 0) then

v_suma_de_retinut = 0

v_retinere = least(v_disponibil,v_suma_de_retinut)
return v_retinere /* Conta CAR */

/* End: Formula: CAR */

CAR_TOTAL

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CAR_TOTAL */

default for CAR_TOTAL_ASG_MONTH is 0

v_car_total = CAR_TOTAL_ASG_MONTH

if (v_car_total <> 0) then v_suma = v_car_total

return v_car_total,

/* Conta CAR */

v_suma

/* End: Formula: CAR_TOTAL */

CAS_ANGAJAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CAS_ANGAJAT vCSL 1 jan 06*/

/* CAS angajat */
default for Baza is 0
default for Baza_neplafonata is 0
default for CM_CAS_ASG_MONTH is 0
/* Globals */
default for CAS_ASIGURAT is 0 /* 9.5 */
default for SAL_MEDIU_ECONOMIE is 0
default for NR_SALARII_CAS is 5

default for BAZA_CAS_ANGAJAT_ASG_MONTH is 0


default for BAZA_CAS_ANGAJAT_PER_MONTH is 0
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for ASG_PRIMARY is ' ' /* Yes / No */
default for ELEMENT_NAME is ' '

inputs are
Baza,
Baza_neplafonata

/* -------------------------------------------------------------------------
Baza CAS angajat
------------------------------------------------------------------------- */
plafon = SAL_MEDIU_ECONOMIE * NR_SALARII_CAS

v_baza_neplafonata = Baza_neplafonata

v_baza_calcul_cas = Baza
x = v_baza_calcul_cas + CM_CAS_ASG_MONTH
/* plafonare */
if (plafon < x) then x = round(plafon, 0)

/* -------------------------------------------------------------------------
End: Baza CAS angajat
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
CAS angajat
------------------------------------------------------------------------- */
v_cas_asigurat = round((CAS_ASIGURAT / 100) * x)

/* ----------------
corectie
------------------- */
if ASG_PRIMARY= 'Yes' and MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
(
b_t = BAZA_CAS_ANGAJAT_PER_MONTH + CM_CAS_ASG_MONTH
if plafon < b_t then b_t = plafon
cas_t = round((CAS_ASIGURAT / 100) * b_t)
b_asg_s = BAZA_CAS_ANGAJAT_PER_MONTH - BAZA_CAS_ANGAJAT_ASG_MONTH
if plafon < b_asg_s then b_asg_s = plafon
cas_asg_s = round((CAS_ASIGURAT / 100) * b_asg_s)

cas_asg_p = v_cas_asigurat
cas_asg_p_corect = cas_t - cas_asg_s
cas_dif= cas_asg_p_corect - cas_asg_p
if cas_dif <> 0 then v_m1 = ELEMENT_NAME + ': CAS dif=' + to_text(cas_dif)

v_cas_asigurat = cas_asg_p_corect
)
/* ----------------
end: corectie
------------------- */
/* -------------------------------------------------------------------------
END: CAS angajat
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Conta
------------------------------------------------------------------------- */
if (v_cas_asigurat <> 0) then v_suma = v_cas_asigurat
/* -------------------------------------------------------------------------
END: Conta
------------------------------------------------------------------------- */

return
/* CAS angajat */
v_baza_calcul_cas,
v_baza_neplafonata,
v_cas_asigurat,

/* Conta CAS angajat */


v_suma,

v_m1

/* End: Formula: CAS_ANGAJAT */

CAS_ANGAJATOR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CAS_ANGAJATOR */

default for BAZA_CAS_ANGAJATOR_ASG_MONTH is 0


default for CM_SANATATE_ASG_MONTH is 0
default for TOTAL_PRESTATII_CAS_ASG_MONTH is 0
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 0
default for ORE_LUCRATE_LUNA_ASG_RUN is 0
default for CAS_ANGAJATOR_CN is 0
default for CAS_ANGAJATOR_CD is 0
default for CAS_ANGAJATOR_CS is 0
default for PR_CONTRIB_AM_SI_BP is 0
default for DURATA_NORMALA_TIMP_LUCRU is 8
default for ASG_HOURS is 0
default for PRIMA_PROFIT_ASG_MONTH is 0
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)

/* coduri lookup
1 = CS
2 = CD
3 = CN
*/

/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0
default for CONTARE_SEPARATA_PROFIT_CAS_ANGAJATOR is ' '
default for ORE_CN_ASG_MONTH is 0
default for ORE_CD_ASG_MONTH is 0
default for ORE_CS_ASG_MONTH is 0
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 1
default for ELEMENT_NAME is ' '

default for VENITURI_CD_ASG_MONTH is 0


default for VENITURI_CS_ASG_MONTH is 0

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3
/* -------------------------------------------------------------------------
Baza CAS
------------------------------------------------------------------------- */
v_baza_calcul_cas = BAZA_CAS_ANGAJATOR_ASG_MONTH
/* -------------------------------------------------------------------------
End: Baza CAS
------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------
CAS angajator
------------------------------------------------------------------------- */
v_m1 = ELEMENT_NAME

/* 1 = CS */
if v_cond_m = 1 then
(
v_baza_calcul_cas_cs = v_baza_calcul_cas
v_pr_cas_angajator = CAS_ANGAJATOR_CS
v_m1 = v_m1 + ': CS=' + to_text(v_pr_cas_angajator) + '%'
)
/* 2 = CD */
if v_cond_m = 2 then
(
v_baza_calcul_cas_cd = v_baza_calcul_cas
v_pr_cas_angajator = CAS_ANGAJATOR_CD
v_m1 = v_m1 + ': CD=' + to_text(v_pr_cas_angajator) + '%'
)
/* 3 = CN */
if v_cond_m = 3 then
(
v_baza_calcul_cas_cn = v_baza_calcul_cas
v_pr_cas_angajator = CAS_ANGAJATOR_CN
v_m1 = v_m1 + ': CN=' + to_text(v_pr_cas_angajator) + '%'
)
if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_cas_angajator = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas, 9)
else
v_cas_angajator = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas, 2)
/* nerotunjit */
v_cas_angajator_1 = ((v_pr_cas_angajator / 100) * v_baza_calcul_cas)
/*-------------------------------------------------------------------------
End: CAS angajator
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
CAS angajator - EXCEPTIE
------------------------------------------------------------------------- */
if ORE_CN_ASG_MONTH <> 0
then
(
v_baza_calcul_cas_cd = VENITURI_CD_ASG_MONTH
v_pr_cas_angajator = CAS_ANGAJATOR_CD
v_cas_angajator_cd = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas_cd, 2)
if ORE_CD_ASG_MONTH <> 0 then
v_m1 = v_m1 + ': CD=' + to_text(v_pr_cas_angajator) + '%'

v_baza_calcul_cas_cs = VENITURI_CS_ASG_MONTH
v_pr_cas_angajator = CAS_ANGAJATOR_CS
v_cas_angajator_cs = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas_cs, 2)
if ORE_CS_ASG_MONTH <> 0 then
v_m1 = v_m1 + ': CS=' + to_text(v_pr_cas_angajator) + '%'

v_baza_calcul_cas_cn = v_baza_calcul_cas - (v_baza_calcul_cas_cd + v_baza_calcul_cas_cs)


v_pr_cas_angajator = CAS_ANGAJATOR_CN
v_cas_angajator_cn = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas_cn, 2)
v_m1 = v_m1 + ': CN=' + to_text(v_pr_cas_angajator) + '%'

v_cas_angajator = v_cas_angajator_cn + v_cas_angajator_cd + v_cas_angajator_cs


/* nerotunjit */
v_cas_angajator_1 = v_cas_angajator
)
else if ORE_CD_ASG_MONTH <> 0 then
(
v_baza_calcul_cas_cs = VENITURI_CS_ASG_MONTH
v_pr_cas_angajator = CAS_ANGAJATOR_CS
v_cas_angajator_cs = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas_cs, 2)
if ORE_CS_ASG_MONTH <> 0 then
v_m1 = v_m1 + ': CS=' + to_text(v_pr_cas_angajator) + '%'

v_baza_calcul_cas_cd = v_baza_calcul_cas - (v_baza_calcul_cas_cs)


v_pr_cas_angajator = CAS_ANGAJATOR_CD
v_cas_angajator_cd = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas_cd, 2)
v_m1 = v_m1 + ': CD=' + to_text(v_pr_cas_angajator) + '%'

v_cas_angajator = v_cas_angajator_cd + v_cas_angajator_cs


/* nerotunjit */
v_cas_angajator_1 = v_cas_angajator
)
else if ORE_CS_ASG_MONTH <> 0 then
(
v_baza_calcul_cas_cs = VENITURI_CS_ASG_MONTH
v_pr_cas_angajator = CAS_ANGAJATOR_CS
v_cas_angajator_cs = round((v_pr_cas_angajator / 100) * v_baza_calcul_cas_cs, 2)
v_m1 = v_m1 + ': CS=' + to_text(v_pr_cas_angajator) + '%'

v_cas_angajator = v_cas_angajator_cs
/* nerotunjit */
v_cas_angajator_1 = v_cas_angajator
)
/* -------------------------------------------------------------------------
End: CAS angajator - EXCEPTIE
------------------------------------------------------------------------- */

/* N. Contributie de asigurari pentru accidente de munca si boli profesionale


(art.140 din Leg.346/2002)
------------------------------------------------------------------------------------------------ */

if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )


then
v_contrib_am_si_bp = round((PR_CONTRIB_AM_SI_BP / 100) * v_baza_calcul_cas, 4)
else
v_contrib_am_si_bp = round((PR_CONTRIB_AM_SI_BP / 100) * v_baza_calcul_cas, 2)

/* End: N. Contributie de asigurari pentru accidente de munca si boli profesionale


(art.140 Leg.346/2002)
------------------------------------------------------------------------------------------------*/

/* Nr mediu de asigurati
--------------------------- */
v_durata_muncii = ASG_HOURS
if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)
then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_zile_lucrate = ORE_LUCRATE_LUNA_ASG_RUN / v_durata_muncii


v_zile_lucratoare_luna = ORE_LUCRATOARE_LUNA_ASG_RUN / v_durata_muncii

v_nr_mediu_asigurati = (v_durata_muncii * v_zile_lucrate) / (v_zile_lucratoare_luna * 8)

/* End: Nr mediu de asigurati


----------------------------------*/

v_contributie_sanatate_cm = CM_SANATATE_ASG_MONTH

v_total_prestatii_cas = TOTAL_PRESTATII_CAS_ASG_MONTH

/* -------------------------------------------------------------------------
Conta
------------------------------------------------------------------------- */

v_cas_prima = 0
v_contrib_am_si_bp_prima = 0
if
/* Contare separata contributii angajator pentru Profit */
(CONTARE_SEPARATA_PROFIT_CAS_ANGAJATOR = 'Y') then
( /* N 1 */

v_prima = PRIMA_PROFIT_ASG_MONTH

/* Conta Prima profit CAS angajator


----------------------------------------- */
/* 1 = CS */
if v_cond_m = 1 then
(
v_pr_cas_angajator = CAS_ANGAJATOR_CS
)
/* 2 = CD */
if v_cond_m = 2 then
(
v_pr_cas_angajator = CAS_ANGAJATOR_CD
)
/* 3 = CN */
if v_cond_m = 3 then
(
v_pr_cas_angajator = CAS_ANGAJATOR_CN
)
if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_cas_prima = round((v_pr_cas_angajator / 100) * v_prima, 4)
else
v_cas_prima = round((v_pr_cas_angajator / 100) * v_prima, 0)

/* Conta Prima profit Fond risc


----------------------------------- */
if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_contrib_am_si_bp_prima = round((PR_CONTRIB_AM_SI_BP / 100) * v_prima, 4)
else
v_contrib_am_si_bp_prima = round((PR_CONTRIB_AM_SI_BP / 100) * v_prima, 2)

) /* N 1 */

/* Conta CAS angajator */


v_suma_cas = v_cas_angajator - v_cas_prima

/* Conta Fond risc */


v_suma_risc = v_contrib_am_si_bp - v_contrib_am_si_bp_prima

/* -------------------------------------------------------------------------
End: Conta
------------------------------------------------------------------------- */

return
/* CAS angajator */
v_baza_calcul_cas_cs,
v_baza_calcul_cas_cd,
v_baza_calcul_cas_cn,
v_baza_calcul_cas,
v_cas_angajator, /* PV */
v_cas_angajator_1,
v_contributie_sanatate_cm,
v_total_prestatii_cas,
v_contrib_am_si_bp,
v_nr_mediu_asigurati,
v_cas_angajator_cn,
v_cas_angajator_cd,
v_cas_angajator_cs,

v_m1,

/* Conta CAS angajator */


v_suma_cas,
/* Conta Fond risc */
v_suma_risc

/* End: Formula: CAS_ANGAJATOR */

CAS_ANGAJAT_DECLARATIE

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CAS_ANGAJAT_DECLARATIE */

default for BAZA_CAS_ANGAJAT_ASG_MONTH is 0


default for CM_ZILE_CONTRIBUTIVE_LUNA_ASG_RUN is 0
default for ASG_HOURS is 0
default for DURATA_NORMALA_TIMP_LUCRU is 8
/* pre-configurat 'Fulltime-Regular' */
default for ASG_EMPLOYMENT_CATEGORY_CODE is 'FR'
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for INDEMNIZATIE_CA_NEREZIDENT_COUNT is 0
default for INDEMNIZATIE_CA_REZIDENT_COUNT is 0

/* coduri lookup
1 = CS
2 = CD
3 = CN
*/

/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for ORE_CN_ASG_RUN is 0
default for ORE_CD_ASG_RUN is 0
default for ORE_CS_ASG_RUN is 0
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 1

default for TOTAL_PRESTATII_ASG_MONTH is 0


default for TOTAL_PRESTATII_ZILE_ASG_MONTH is 0

default for PROGRAM_PARTIAL_ASG_RUN is 0

v_p_part = PROGRAM_PARTIAL_ASG_RUN

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3
/* -----------------------------------------
Anulare calcul
-------------------------------------------- */
/*
NU se completeaza pentru:
-membru CA
-persoanele in Suspendare contract
*/
v_m1 = ELEMENT_NAME + ': '
if
ASG_EMPLOYMENT_CATEGORY_CODE = 'CA_REZ' or
ASG_EMPLOYMENT_CATEGORY_CODE = 'CA_NREZ'
then
(
v_m1 = v_m1 + ' membru CA, nu calculeaza CAS'
Return v_m1
)

if
BAZA_CAS_ANGAJAT_ASG_MONTH = 0 and
CM_ZILE_CONTRIBUTIVE_LUNA_ASG_RUN = 0 then
(
v_m1 = v_m1 + ' Fara venit si zile contributive, nu calculeaza CAS'
Return v_m1
)
/* -----------------------------------------
End:anulare calcul
-------------------------------------------- */

/* -----------------------------
Baza CAS angajat
-------------------------------- */
v_baza_calcul_cas = BAZA_CAS_ANGAJAT_ASG_MONTH
/* -----------------------------
End: Baza CAS angajat
-------------------------------- */

/* ------------------------------------------------------------------------
Declaratie
------------------------------------------------------------------------- */

v_norma_zilnica = 0
v_contr_munca_timp_partial = 0
v_pensionar = 0
v_zile_total = 0
v_zile_cs = 0
v_zile_cd = 0
v_zile_cn = 0
v_zile_prestatii = 0
v_baza_calcul_cas_cs = 0
v_baza_calcul_cas_cd = 0
v_baza_calcul_cas_cn = 0
v_total_prestatii = 0
v_total_prestatii_cas = 0
v_contract_munca = 0

/* calculeaza norma zilnica (intreaga sau partiala)


---------------------------------------------------------------*/

v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if
(v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU) then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

if
(MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'P' )
then
/* pentru pensionari */
v_pensionar = v_durata_muncii
else
/* pentru ceilalti angajati */
(
if
(ASG_EMPLOYMENT_CATEGORY_CODE = 'FR' or ASG_EMPLOYMENT_CATEGORY_CODE = 'FT')
then
v_norma_zilnica = v_durata_muncii
else
v_contr_munca_timp_partial = v_durata_muncii

/* Exceptie */
if (v_p_part <> 0) then
(v_contr_munca_timp_partial = v_p_part
v_norma_zilnica = v_p_part)
/* End: Exceptie */
)
/* End: calculeaza norma zilnica (intreaga sau partiala)
---------------------------------------------------------------------*/

/* Contract individual de munca


---------------------------------------------------------------------*/
if
/* Se completeaz cu:
1 pentru asiguraii cu contract de munc cu norm ntreag,
0 n rest */
(ASG_EMPLOYMENT_CATEGORY_CODE = 'FR' or ASG_EMPLOYMENT_CATEGORY_CODE = 'FT')
then
v_contract_munca = 1

/* Exceptie */
if (v_p_part <> 0) then v_contract_munca = 0
/* End: Exceptie */

/* pentru pensionari */
if (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'P' ) then v_contract_munca = 0

/* End: Contract individual de munca


---------------------------------------------------------------------*/

/* calculeaza venitul realizat


--------------------------------------------------------------------- */

if v_cond_m = 1 then v_baza_calcul_cas_cs = v_baza_calcul_cas


if v_cond_m = 2 then v_baza_calcul_cas_cd = v_baza_calcul_cas
if v_cond_m = 3 then v_baza_calcul_cas_cn = v_baza_calcul_cas

/* -----------------------------------
CAS angajat - EXCEPTIE
-------------------------------------- */
if ORE_CN_ASG_RUN <> 0
then
(
v_baza_calcul_cas_cd = v_baza_calcul_cas * ORE_CD_ASG_RUN /
ORE_LUCRATOARE_LUNA_ASG_RUN
v_baza_calcul_cas_cs = v_baza_calcul_cas * ORE_CS_ASG_RUN /
ORE_LUCRATOARE_LUNA_ASG_RUN
v_baza_calcul_cas_cn = v_baza_calcul_cas - (v_baza_calcul_cas_cd + v_baza_calcul_cas_cs)
)
else if ORE_CD_ASG_RUN <> 0 then
(
v_baza_calcul_cas_cs = v_baza_calcul_cas * ORE_CS_ASG_RUN /
ORE_LUCRATOARE_LUNA_ASG_RUN
v_baza_calcul_cas_cd = v_baza_calcul_cas - (v_baza_calcul_cas_cs)
)
else if ORE_CS_ASG_RUN <> 0 then
(
v_baza_calcul_cas_cs = v_baza_calcul_cas * ORE_CS_ASG_RUN /
ORE_LUCRATOARE_LUNA_ASG_RUN
)
/* ---------------------------------------
End: CAS angajat - EXCEPTIE
------------------------------------------ */

/* End: calculeaza venitul realizat


---------------------------------------------------------------------*/

/* calculeaza zilele lucrate sau de prestatii


--------------------------------------------------------------------- */
v_zile_total = CM_ZILE_CONTRIBUTIVE_LUNA_ASG_RUN
v_zile_prestatii = TOTAL_PRESTATII_ZILE_ASG_MONTH

if v_cond_m = 1 then
(
v_zile_cs = v_zile_total - v_zile_prestatii
if (v_zile_cs = 0 and v_baza_calcul_cas_cs <> 0) then
v_m1 = ELEMENT_NAME + ': Atentie'
+ ' Baza CS=' + to_text(v_baza_calcul_cas_cs)
+ ' Zile CS=' + to_text(v_zile_cs)
)

if v_cond_m = 2 then
(
v_zile_cd = v_zile_total - v_zile_prestatii
if (v_zile_cd = 0 and v_baza_calcul_cas_cd <> 0) then
v_m1 = ELEMENT_NAME + ': Atentie'
+ ' Baza CD=' + to_text(v_baza_calcul_cas_cd)
+ ' Zile CD=' + to_text(v_zile_cd)
)

if v_cond_m = 3 then
(
v_zile_cn = v_zile_total - v_zile_prestatii
if (v_zile_cn = 0 and v_baza_calcul_cas_cn <> 0) then
v_m1 = ELEMENT_NAME + ': Atentie'
+ ' Baza CN=' + to_text(v_baza_calcul_cas_cn)
+ ' Zile CN=' + to_text(v_zile_cn)
)

/* -----------------------------------
CAS angajator - EXCEPTIE
-------------------------------------- */
if ORE_CN_ASG_RUN + ORE_CD_ASG_RUN + ORE_CS_ASG_RUN <> 0 then
(
v_zile_cn = ORE_CN_ASG_RUN
v_zile_cd = ORE_CD_ASG_RUN
v_zile_cs = ORE_CS_ASG_RUN
)
/* ---------------------------------------
End: CAS angajator - EXCEPTIE
------------------------------------------ */

/* End: calculeaza zilele lucrate sau de prestatii


--------------------------------------------------------------------- */

/* calculeaza prestatii
---------------------------------------------------------------------*/

/* v_total_prestatii_de_asigurari_sociale */
v_total_prestatii = TOTAL_PRESTATII_ASG_MONTH

/* din care suportate din BASS */


v_total_prestatii_cas = TOTAL_PRESTATII_CAS_ASG_MONTH

/* End: calculeaza prestatii


--------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
End: Declaratie
------------------------------------------------------------------------- */

return
/* CAS angajat Declaratie */
v_norma_zilnica,
v_contr_munca_timp_partial,
v_pensionar,
v_zile_total,
v_zile_cs,
v_zile_cd,
v_zile_cn,
v_zile_prestatii,
v_baza_calcul_cas_cs,
v_baza_calcul_cas_cd,
v_baza_calcul_cas_cn,
v_total_prestatii,
v_total_prestatii_cas,
v_contract_munca,

v_m1

/* End: Formula: CAS_ANGAJAT_DECLARATIE */

CCP_INDEMNIZATIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CCP_INDEMNIZATIE */

default for ZILE is 0


default for ORE is 0
default for FEL is ' ' /* cod = xxZZZ */

default for SALARIU_BAZA_ORAR_ASG_RUN is 0


/* procente spor */
default for PROCENT_SPOR_FIDELITATE_ASG_RUN is 0
default for PROCENT_SPOR_VECHIME_ASG_RUN is 0
default for SPORURI_NEGOCIATE_PROCENTE_ASG_RUN is 0
default for INDEMNIZATIE_CONDUCERE_ASG_RUN is 0
default for INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN is 0
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 0
default for INTRERUPERE_LUCRU_PROCENT is 0

inputs are
ZILE,
ORE,
FEL

v_sp_procente = PROCENT_SPOR_FIDELITATE_ASG_RUN
+ PROCENT_SPOR_VECHIME_ASG_RUN

v_indemn = round( SALARIU_BAZA_ORAR_ASG_RUN * (1 + v_sp_procente / 100) * ORE, 2)

/* ----------------------------------------------
20 Concediu pentru alaptare
----------------------------------------------- */
if (substr(FEL,1,2) = '20') then
v_indemn = round( SALARIU_BAZA_ORAR_ASG_RUN * (1 + v_sp_procente / 100) * (ZILE * 2) )

/* ----------------------------------------------
40-activitate sindicala
----------------------------------------------- */
if (substr(FEL,1,2) = '40') then
(
v_sp_procente = SPORURI_NEGOCIATE_PROCENTE_ASG_RUN
y = SALARIU_BAZA_ORAR_ASG_RUN * (1 + v_sp_procente / 100)
+ (INDEMNIZATIE_CONDUCERE_ASG_RUN
+ INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN) / ORE_LUCRATOARE_LUNA_ASG_RUN
v_indemn = round( y * ORE, 2)
)

/* ----------------------------------------------
80- ntreruperea lucrului i regim de ateptare
----------------------------------------------- */
if (substr(FEL,1,2) = '80') then
(
y = SALARIU_BAZA_ORAR_ASG_RUN * INTRERUPERE_LUCRU_PROCENT / 100
v_indemn = round( y * ORE, 2)
)

/* ----------------------------------------------
90- Indemnizaie pentru perioada nelucrat n timpul preavizului
----------------------------------------------- */
if (substr(FEL,1,2) = '90') then
(
v_sp_procente = SPORURI_NEGOCIATE_PROCENTE_ASG_RUN
y = SALARIU_BAZA_ORAR_ASG_RUN * (1 + v_sp_procente / 100)
+ (INDEMNIZATIE_CONDUCERE_ASG_RUN
+ INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN) / ORE_LUCRATOARE_LUNA_ASG_RUN
v_indemn = round( y * ORE, 2)
)

return
/* CCP Indemnizatie */
v_indemn

/* End: Formula: CCP_INDEMNIZATIE */

CHECK_RATE_TYPE
/**************************************************************
FORMULA NAME: CHECK_RATE_TYPE
FORMULA TYPE: User Table Validation
DESCRIPTION: Check rate type exists in GL_DAILY_CONVERSION_TYPES
History
02 Feb 1999 wkerr First Created.
***************************************************************/
INPUTS ARE entry_value (text)
rt = check_rate_type(entry_value)
IF rt = -1 THEN
(
formula_status = 'E'
formula_message = 'Rate type does not exist.'
)
ELSE IF rt = -2 THEN
(
formula_status = 'E'
formula_message = 'User Rate type is not allowed.'
)
ELSE
formula_status = 'S'
RETURN formula_status, formula_message

CHIRIE_1

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CHIRIE_1 */

default for REST_PLATA_2_ASG_MONTH is 0


default for ELEMENT_NAME is ' '
default for RATA is 0
default for CHIRIE_1_NEACOPERIT_ASG_ITD is 0

inputs are RATA

v_disponibil = REST_PLATA_2_ASG_MONTH
v_rata = RATA
v_neacoperit_initial = CHIRIE_1_NEACOPERIT_ASG_ITD

v_rata_de_platit = (v_rata + v_neacoperit_initial)

v_rata_retinuta = least(v_disponibil,v_rata_de_platit)

v_neacoperit_final = v_rata_de_platit - v_rata_retinuta


if (v_neacoperit_final > 0) then
v_mesaj_1 = ELEMENT_NAME + ' : Retinere neacoperita = ' + to_text(v_neacoperit_final)

return
v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta

/* End: Formula: CHIRIE_1 */

CHIRII

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CHIRII */

default for CHIRII_ASG_MONTH is 0

v_chirii = CHIRII_ASG_MONTH

if (v_chirii <> 0) then v_suma = v_chirii

return v_chirii,

/* Conta chirii */

v_suma

/* End: Formula: CHIRII */

CM

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CM (vs. 01 feb 2006)*/

default for DATA_INCEPUT_CM is '01-FEB-2000' (DATE)


default for DATA_SFARSIT_CM is '01-FEB-2000' (DATE)
default for TIP_BOALA is '00'
default for IN_CONTINUARE is 'N'

/* CM corectii
----------------*/
default for CM_1_CORECTII_ZILE_INTR_ENTRY_VALUE is 0
default for CM_1_CORECTII_ZILE_CAS_ENTRY_VALUE is 0
default for CM_1_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77

default for CM_2_CORECTII_ZILE_INTR_ENTRY_VALUE is 0


default for CM_2_CORECTII_ZILE_CAS_ENTRY_VALUE is 0
default for CM_2_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77

default for CM_3_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0


default for CM_3_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0
default for CM_3_CORECTII_ZILE_INTR_ENTRY_VALUE is 0
default for CM_3_CORECTII_ZILE_CAS_ENTRY_VALUE is 0
default for CM_3_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77

default for CM_4_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0


default for CM_4_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0
default for CM_4_CORECTII_ZILE_INTR_ENTRY_VALUE is 0
default for CM_4_CORECTII_ZILE_CAS_ENTRY_VALUE is 0
default for CM_4_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77

default for CM_5_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0


default for CM_5_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0
default for CM_5_CORECTII_ZILE_INTR_ENTRY_VALUE is 0
default for CM_5_CORECTII_ZILE_CAS_ENTRY_VALUE is 0
default for CM_5_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77
/* CM anterior
----------------*/
default for CM_1_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77
default for CM_2_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77
default for CM_3_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77
default for CM_4_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77
default for CM_5_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE is -77
/* balante CM
----------------*/
default for CM_1_MEDIE_ZILNICA_ASG_ITD is -77
default for CM_2_MEDIE_ZILNICA_ASG_ITD is -77
default for CM_3_MEDIE_ZILNICA_ASG_ITD is -77
default for CM_4_MEDIE_ZILNICA_ASG_ITD is -77
default for CM_5_MEDIE_ZILNICA_ASG_ITD is -77
/* CM acordat
---------------*/
default for CM_1_ZILE_SPITALIZARE_INTR_ASG_ITD is 0
default for CM_1_ZILE_SPITALIZARE_CAS_ASG_ITD is 0
default for CM_1_ZILE_INTR_ASG_ITD is 0
default for CM_1_ZILE_CAS_ASG_ITD is 0

default for CM_2_ZILE_SPITALIZARE_INTR_ASG_ITD is 0


default for CM_2_ZILE_SPITALIZARE_CAS_ASG_ITD is 0
default for CM_2_ZILE_INTR_ASG_ITD is 0
default for CM_2_ZILE_CAS_ASG_ITD is 0

default for CM_3_ZILE_SPITALIZARE_INTR_ASG_ITD is 0


default for CM_3_ZILE_SPITALIZARE_CAS_ASG_ITD is 0
default for CM_3_ZILE_INTR_ASG_ITD is 0
default for CM_3_ZILE_CAS_ASG_ITD is 0

default for CM_4_ZILE_SPITALIZARE_INTR_ASG_ITD is 0


default for CM_4_ZILE_SPITALIZARE_CAS_ASG_ITD is 0
default for CM_4_ZILE_INTR_ASG_ITD is 0
default for CM_4_ZILE_CAS_ASG_ITD is 0

default for CM_5_ZILE_SPITALIZARE_INTR_ASG_ITD is 0


default for CM_5_ZILE_SPITALIZARE_CAS_ASG_ITD is 0
default for CM_5_ZILE_INTR_ASG_ITD is 0
default for CM_5_ZILE_CAS_ASG_ITD is 0

default for CM_VENITURI_ASG_MONTH is 0 /* RetroPay */


default for CM_VENITURI_1_ASG_RUN is 0
default for CM_VENITURI_2_ASG_RUN is 0
default for CM_VENITURI_3_ASG_RUN is 0
default for CM_VENITURI_4_ASG_RUN is 0
default for CM_VENITURI_5_ASG_RUN is 0
default for CM_VENITURI_6_ASG_RUN is 0
default for CM_VENITURI_7_ASG_RUN is 0
default for CM_VENITURI_8_ASG_RUN is 0
default for CM_VENITURI_9_ASG_RUN is 0
default for CM_VENITURI_10_ASG_RUN is 0
default for CM_VENITURI_11_ASG_RUN is 0
default for CM_VENITURI_12_ASG_RUN is 0

default for CM_ZILE_CONTRIBUTIVE_1_ASG_RUN is 0


default for CM_ZILE_CONTRIBUTIVE_2_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_3_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_4_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_5_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_6_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_7_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_8_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_9_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_10_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_11_ASG_RUN is 0
default for CM_ZILE_CONTRIBUTIVE_12_ASG_RUN is 0

default for ZILE_LUCRATOARE_1_ASG_RUN is 0


default for ZILE_LUCRATOARE_2_ASG_RUN is 0
default for ZILE_LUCRATOARE_3_ASG_RUN is 0
default for ZILE_LUCRATOARE_4_ASG_RUN is 0
default for ZILE_LUCRATOARE_5_ASG_RUN is 0
default for ZILE_LUCRATOARE_6_ASG_RUN is 0
default for ZILE_LUCRATOARE_7_ASG_RUN is 0
default for ZILE_LUCRATOARE_8_ASG_RUN is 0
default for ZILE_LUCRATOARE_9_ASG_RUN is 0
default for ZILE_LUCRATOARE_10_ASG_RUN is 0

default for CM_ORE_LUCRATOARE_LUNA_ASG_MONTH is 0


default for SAL_MEDIU_ECONOMIE is 0
default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2000' (DATE)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2000' (DATE)

default for PROCESARE_2_ASG_RUN is 0 /* Calcul luna */


default for PROCESARE_3_ASG_RUN is 0 /* Calcul CM */
default for PROCESARE_4_ASG_RUN is 0 /* Calcul salarii */

default for CM_1_CFP_ASG_MONTH is 0


default for CM_2_CFP_ASG_MONTH is 0
default for CM_3_CFP_ASG_MONTH is 0
default for CM_4_CFP_ASG_MONTH is 0
default for CM_5_CFP_ASG_MONTH is 0

default for CM_1_CO_ASG_MONTH is 0


default for CM_2_CO_ASG_MONTH is 0
default for CM_3_CO_ASG_MONTH is 0
default for CM_4_CO_ASG_MONTH is 0
default for CM_5_CO_ASG_MONTH is 0

/* 1 fractiune de luna - in luna curenta */


default for CM_INDEMNIZATIE_ASG_MONTH is 0
default for CM_ZILE_ASG_MONTH is 0
default for CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH is 0
default for CM_VENIT_FIX_ZI_ASG_MONTH is 0
default for CM_VENIT_VAR_ZI_ASG_MONTH is 0
default for CM_VENIT_VARIABIL_NELINIAR_ZI_ASG_MONTH is 0
/* END: 1 fractiune de luna - in luna curenta */
/* CM total
---------------*/
default for CM_1_TOTAL_ZILE_INTR_ASG_MONTH is 0
default for CM_1_TOTAL_ZILE_CAS_ASG_MONTH is 0
default for CM_1_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH is 0
default for CM_1_TOTAL_BCLI_ASG_MONTH is 0

default for CM_2_TOTAL_ZILE_INTR_ASG_MONTH is 0


default for CM_2_TOTAL_ZILE_CAS_ASG_MONTH is 0
default for CM_2_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH is 0
default for CM_2_TOTAL_BCLI_ASG_MONTH is 0

default for CM_3_TOTAL_ZILE_INTR_ASG_MONTH is 0


default for CM_3_TOTAL_ZILE_CAS_ASG_MONTH is 0
default for CM_3_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH is 0
default for CM_3_TOTAL_BCLI_ASG_MONTH is 0

default for CM_4_TOTAL_ZILE_INTR_ASG_MONTH is 0


default for CM_4_TOTAL_ZILE_CAS_ASG_MONTH is 0
default for CM_4_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH is 0
default for CM_4_TOTAL_BCLI_ASG_MONTH is 0

default for CM_5_TOTAL_ZILE_INTR_ASG_MONTH is 0


default for CM_5_TOTAL_ZILE_CAS_ASG_MONTH is 0
default for CM_5_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH is 0
default for CM_5_TOTAL_BCLI_ASG_MONTH is 0

default for CM_1_TOTAL_INCEPUT_CM_ASG_MONTH is 0


default for CM_2_TOTAL_INCEPUT_CM_ASG_MONTH is 0
default for CM_3_TOTAL_INCEPUT_CM_ASG_MONTH is 0
default for CM_4_TOTAL_INCEPUT_CM_ASG_MONTH is 0
default for CM_5_TOTAL_INCEPUT_CM_ASG_MONTH is 0

default for CM_1_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE is 0


default for CM_2_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE is 0
default for CM_3_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE is 0
default for CM_4_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE is 0
default for CM_5_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE is 0

default for CM_1_TOTAL_BCLI_ENTRY_VALUE is 0


default for CM_2_TOTAL_BCLI_ENTRY_VALUE is 0
default for CM_3_TOTAL_BCLI_ENTRY_VALUE is 0
default for CM_4_TOTAL_BCLI_ENTRY_VALUE is 0
default for CM_5_TOTAL_BCLI_ENTRY_VALUE is 0

default for CM_SALARIU_BAZA_LUNAR_ASG_MONTH is 0

inputs are
DATA_INCEPUT_CM,
DATA_SFARSIT_CM,
TIP_BOALA,
IN_CONTINUARE

TB = TIP_BOALA
if PAY_PROC_PERIOD_START_DATE > DATA_INCEPUT_CM then
(v_stop = ELEMENT_NAME + ' Stop'
return v_stop)
/* -----------------
CM timp
----------------- */
if (PROCESARE_3_ASG_RUN = 0) and
not (PROCESARE_4_ASG_RUN = 1 and ELEMENT_NAME = 'CM 5') then
/* procesare numai ca element de timp */
(
v_lansare_suspendare = ELEMENT_NAME
v_data_inceperii = DATA_INCEPUT_CM
v_data_incheierii = DATA_SFARSIT_CM
v_cod_indemnizatie = TB

/* CM [nr] CFP
----------------------- */
if (PROCESARE_2_ASG_RUN = 1) then
/* procesare numai la Calcul luna */
(
if (ELEMENT_NAME = 'CM 1') then v_lans_cm_1_cfp = DATA_INCEPUT_CM
if (ELEMENT_NAME = 'CM 2') then v_lans_cm_2_cfp = DATA_INCEPUT_CM
if (ELEMENT_NAME = 'CM 3') then v_lans_cm_3_cfp = DATA_INCEPUT_CM
if (ELEMENT_NAME = 'CM 4') then v_lans_cm_4_cfp = DATA_INCEPUT_CM
if (ELEMENT_NAME = 'CM 5') then v_lans_cm_5_cfp = DATA_INCEPUT_CM
)
/* End: CM [nr] CFP
----------------------- */

return
/* CM Suspendare contract */
v_lansare_suspendare,
v_data_inceperii,
v_data_incheierii,
v_cod_indemnizatie,
/* CM [nr] CFP */
v_lans_cm_1_cfp, /* Data inceput CM */
v_lans_cm_2_cfp,
v_lans_cm_3_cfp,
v_lans_cm_4_cfp,
v_lans_cm_5_cfp
)

/* Calcul CM (timp + indemn) */


v_lansare_suspendare = ELEMENT_NAME
v_data_inceperii = DATA_INCEPUT_CM
v_data_incheierii = DATA_SFARSIT_CM
v_cod_indemnizatie = TB
/* -----------------
End: CM timp
----------------- */
CZ = '1'
if (TB = '02' or TB = '03' or TB = '04' or TB = '22' or TB = '23' or TB = '24' or TB = '10' or TB = '11') then
CZ = '2'

/* CASS */
v_vn_1 = CM_VENITURI_1_ASG_RUN + CM_VENITURI_ASG_MONTH
v_vn_2 = CM_VENITURI_2_ASG_RUN
v_vn_3 = CM_VENITURI_3_ASG_RUN
v_vn_4 = CM_VENITURI_4_ASG_RUN
v_vn_5 = CM_VENITURI_5_ASG_RUN
v_vn_6 = CM_VENITURI_6_ASG_RUN
v_vn_7 = CM_VENITURI_7_ASG_RUN
v_vn_8 = CM_VENITURI_8_ASG_RUN
v_vn_9 = CM_VENITURI_9_ASG_RUN
v_vn_10 = CM_VENITURI_10_ASG_RUN
v_vn_11 = CM_VENITURI_11_ASG_RUN
v_vn_12 = CM_VENITURI_12_ASG_RUN
if CZ = '2' then
( /* CAS */
V_S5 = SAL_MEDIU_ECONOMIE * 5
if (V_S5 < v_vn_1) then v_vn_1 = V_S5
if (V_S5 < v_vn_2) then v_vn_2 = V_S5
if (V_S5 < v_vn_3) then v_vn_3 = V_S5
if (V_S5 < v_vn_4) then v_vn_4 = V_S5
if (V_S5 < v_vn_5) then v_vn_5 = V_S5
if (V_S5 < v_vn_6) then v_vn_6 = V_S5
if (V_S5 < v_vn_7) then v_vn_7 = V_S5
if (V_S5 < v_vn_8) then v_vn_8 = V_S5
if (V_S5 < v_vn_9) then v_vn_9 = V_S5
if (V_S5 < v_vn_10) then v_vn_10 = V_S5
if (V_S5 < v_vn_11) then v_vn_11 = V_S5
if (V_S5 < v_vn_12) then v_vn_12 = V_S5
) /* end: CAS */

v_zc_1 = CM_ZILE_CONTRIBUTIVE_1_ASG_RUN
v_zc_2 = CM_ZILE_CONTRIBUTIVE_2_ASG_RUN
v_zc_3 = CM_ZILE_CONTRIBUTIVE_3_ASG_RUN
v_zc_4 = CM_ZILE_CONTRIBUTIVE_4_ASG_RUN
v_zc_5 = CM_ZILE_CONTRIBUTIVE_5_ASG_RUN
v_zc_6 = CM_ZILE_CONTRIBUTIVE_6_ASG_RUN
v_zc_7 = CM_ZILE_CONTRIBUTIVE_7_ASG_RUN
v_zc_8 = CM_ZILE_CONTRIBUTIVE_8_ASG_RUN
v_zc_9 = CM_ZILE_CONTRIBUTIVE_9_ASG_RUN
v_zc_10 = CM_ZILE_CONTRIBUTIVE_10_ASG_RUN
v_zc_11 = CM_ZILE_CONTRIBUTIVE_11_ASG_RUN
v_zc_12 = CM_ZILE_CONTRIBUTIVE_12_ASG_RUN

v_zl_1 = ZILE_LUCRATOARE_1_ASG_RUN
v_zl_2 = ZILE_LUCRATOARE_2_ASG_RUN
v_zl_3 = ZILE_LUCRATOARE_3_ASG_RUN
v_zl_4 = ZILE_LUCRATOARE_4_ASG_RUN
v_zl_5 = ZILE_LUCRATOARE_5_ASG_RUN
v_zl_6 = ZILE_LUCRATOARE_6_ASG_RUN
v_zl_7 = ZILE_LUCRATOARE_7_ASG_RUN
v_zl_8 = ZILE_LUCRATOARE_8_ASG_RUN
v_zl_9 = ZILE_LUCRATOARE_9_ASG_RUN
v_zl_10 = ZILE_LUCRATOARE_10_ASG_RUN

LC_EX_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MON-YY')


LC_EX_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MON-YY')
LC_EX_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MON-YY')
LC_EX_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MON-YY')
LC_EX_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MON-YY')
LC_EX_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MON-YY')
LC_EX_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MON-YY')

LB_EX_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MON-YY')


LB_EX_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MON-YY')
LB_EX_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MON-YY')
LB_EX_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MON-YY')
LB_EX_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MON-YY')

v_in_continuare = IN_CONTINUARE
/* ----------------
context
---------------- */
if (ELEMENT_NAME = 'CM 1') Then
(MED_COR = CM_1_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE
MED = CM_1_MEDIE_ZILNICA_ASG_ITD
MED_e = to_number(ELEMENT_HISTORY('CM 1 luna','Medie zilnica CM', 1))
if (TB = '10' or TB = '16' or TB = '11') then
MED_e = to_number(ELEMENT_HISTORY('CM 1 luna','Bcli', 1))
if (MED_e = -1) then MED_e = 0

if (v_in_continuare = 'D') then


( /* N 1 */
MED_e = 0
if (TB = '10' or TB = '16' or TB = '11')
then
(
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 5 Total','Bcli', 1)))
+ CM_5_TOTAL_BCLI_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 4 Total','Bcli', 1)))
+ CM_4_TOTAL_BCLI_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 3 Total','Bcli', 1)))
+ CM_3_TOTAL_BCLI_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 2 Total','Bcli', 1)))
+ CM_2_TOTAL_BCLI_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 1 Total','Bcli', 1)))
+ CM_1_TOTAL_BCLI_ENTRY_VALUE
)
else
(
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 5 Total','Medie zilnica CM', 1)))
+ CM_5_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 4 Total','Medie zilnica CM', 1)))
+ CM_4_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 3 Total','Medie zilnica CM', 1)))
+ CM_3_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 2 Total','Medie zilnica CM', 1)))
+ CM_2_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE
if (MED_e = 0) then
MED_e = greatest(0, to_number(ELEMENT_HISTORY('CM 1 Total','Medie zilnica CM', 1)))
+ CM_1_TOTAL_MEDIE_ZILNICA_CM_ENTRY_VALUE
)
MED = MED_e

x=0
if (x = 0) then
x = greatest(0, to_number(ELEMENT_HISTORY('CM 5 Total','Inceput CM', 1)))
if (x = 0) then
x = greatest(0, to_number(ELEMENT_HISTORY('CM 4 Total','Inceput CM', 1)))
if (x = 0) then
x = greatest(0, to_number(ELEMENT_HISTORY('CM 3 Total','Inceput CM', 1)))
if (x = 0) then
x = greatest(0, to_number(ELEMENT_HISTORY('CM 2 Total','Inceput CM', 1)))
if (x = 0) then
x = greatest(0, to_number(ELEMENT_HISTORY('CM 1 Total','Inceput CM', 1)))
v_d_i_cm = ADD_DAYS(to_date('01/01/2004','DD/MM/YYYY'), x)
) /* N 1 */

MED_ANT = CM_1_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE
v_CM_var = CM_1_CO_ASG_MONTH
v_CM_CFP = CM_1_CFP_ASG_MONTH)

If (ELEMENT_NAME = 'CM 2') Then


(MED_COR = CM_2_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE
MED = CM_2_MEDIE_ZILNICA_ASG_ITD
MED_e = to_number(ELEMENT_HISTORY('CM 2 luna','Medie zilnica CM', 1))
if (TB = '10' or TB = '16' or TB = '11') then
MED_e = to_number(ELEMENT_HISTORY('CM 2 luna','Bcli', 1))
if (MED_e = -1) then MED_e = 0

if (v_in_continuare = 'D') then


(MED = 0
if (TB = '10' or TB = '16' or TB = '11')
then MED = CM_1_TOTAL_BCLI_ASG_MONTH
else MED = CM_1_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH
MED_e = MED
v_d_i_cm =
ADD_DAYS(to_date('01/01/2004','DD/MM/YYYY'), CM_1_TOTAL_INCEPUT_CM_ASG_MONTH))

MED_ANT = CM_2_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE
v_CM_var = CM_2_CO_ASG_MONTH
v_CM_CFP = CM_2_CFP_ASG_MONTH)

If (ELEMENT_NAME = 'CM 3') Then


(MED_COR = CM_3_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE
MED = CM_3_MEDIE_ZILNICA_ASG_ITD
MED_e = to_number(ELEMENT_HISTORY('CM 3 luna','Medie zilnica CM', 1))
if (TB = '10' or TB = '16' or TB = '11') then
MED_e = to_number(ELEMENT_HISTORY('CM 3 luna','Bcli', 1))
if (MED_e = -1) then MED_e = 0

if (v_in_continuare = 'D') then


(MED = 0
if (TB = '10' or TB = '16' or TB = '11')
then MED = CM_2_TOTAL_BCLI_ASG_MONTH
else MED = CM_2_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH
MED_e = MED
v_d_i_cm =
ADD_DAYS(to_date('01/01/2004','DD/MM/YYYY'), CM_2_TOTAL_INCEPUT_CM_ASG_MONTH))

MED_ANT = CM_3_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE
v_CM_var = CM_3_CO_ASG_MONTH
v_CM_CFP = CM_3_CFP_ASG_MONTH)

If (ELEMENT_NAME = 'CM 4') Then


(MED_COR = CM_4_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE
MED = CM_4_MEDIE_ZILNICA_ASG_ITD
MED_e = to_number(ELEMENT_HISTORY('CM 4 luna','Medie zilnica CM', 1))
if (TB = '10' or TB = '16' or TB = '11') then
MED_e = to_number(ELEMENT_HISTORY('CM 4 luna','Bcli', 1))
if (MED_e = -1) then MED_e = 0
if (v_in_continuare = 'D') then
(MED = 0
if (TB = '10' or TB = '16' or TB = '11')
then MED = CM_3_TOTAL_BCLI_ASG_MONTH
else MED = CM_3_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH
MED_e = MED
v_d_i_cm =
ADD_DAYS(to_date('01/01/2004','DD/MM/YYYY'), CM_3_TOTAL_INCEPUT_CM_ASG_MONTH))

MED_ANT = CM_4_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE
v_CM_var = CM_4_CO_ASG_MONTH
v_CM_CFP = CM_4_CFP_ASG_MONTH)

If (ELEMENT_NAME = 'CM 5') Then


(MED_COR = CM_5_CORECTII_MEDIE_ZILNICA_CM_ENTRY_VALUE
MED = CM_5_MEDIE_ZILNICA_ASG_ITD
MED_e = to_number(ELEMENT_HISTORY('CM 5 luna','Medie zilnica CM', 1))
if (TB = '10' or TB = '16' or TB = '11') then
MED_e = to_number(ELEMENT_HISTORY('CM 5 luna','Bcli', 1))
if (MED_e = -1) then MED_e = 0

if (v_in_continuare = 'D') then


(MED = 0
if (TB = '10' or TB = '16' or TB = '11')
then MED = CM_4_TOTAL_BCLI_ASG_MONTH
else MED = CM_4_TOTAL_MEDIE_ZILNICA_CM_ASG_MONTH
MED_e = MED
v_d_i_cm =
ADD_DAYS(to_date('01/01/2004','DD/MM/YYYY'), CM_4_TOTAL_INCEPUT_CM_ASG_MONTH))

MED_ANT = CM_5_ANTERIOR_MEDIE_ZILNICA_CM_ENTRY_VALUE
v_CM_var = CM_5_CO_ASG_MONTH
v_CM_CFP = CM_5_CFP_ASG_MONTH)
/* ----------------
End: context
---------------- */
v_data_inceput_CM = DATA_INCEPUT_CM
v_data_sfarsit_CM = DATA_SFARSIT_CM
/* -------------------------------------------------------------------------------
zile deja acordate in cazul CM in continuare:
Zile CM acordate - sold inceput luna
-------------------------------------------------------------------------------- */
if (ELEMENT_NAME = 'CM 1') then
(v_zile_spital_acord_intr = CM_1_ZILE_SPITALIZARE_INTR_ASG_ITD
v_zile_spital_acord_cas = CM_1_ZILE_SPITALIZARE_CAS_ASG_ITD
v_zile_acordate_intr = CM_1_ZILE_INTR_ASG_ITD
v_zile_acordate_cas = CM_1_ZILE_CAS_ASG_ITD

if (v_in_continuare = 'D') then


(v_z_i = 0
v_z_c = 0
if (v_z_i = 0 and v_z_c = 0) then
(v_z_i = greatest(0, to_number(ELEMENT_HISTORY('CM 5 Total','Zile INTR', 1)))
v_z_c = greatest(0, to_number(ELEMENT_HISTORY('CM 5 Total','Zile CAS', 1))) )
if (v_z_i = 0 and v_z_c = 0) then
(v_z_i = greatest(0, to_number(ELEMENT_HISTORY('CM 4 Total','Zile INTR', 1)))
v_z_c = greatest(0, to_number(ELEMENT_HISTORY('CM 4 Total','Zile CAS', 1))) )
if (v_z_i = 0 and v_z_c = 0) then
(v_z_i = greatest(0, to_number(ELEMENT_HISTORY('CM 3 Total','Zile INTR', 1)))
v_z_c = greatest(0, to_number(ELEMENT_HISTORY('CM 3 Total','Zile CAS', 1))) )
if (v_z_i = 0 and v_z_c = 0) then
(v_z_i = greatest(0, to_number(ELEMENT_HISTORY('CM 2 Total','Zile INTR', 1)))
v_z_c = greatest(0, to_number(ELEMENT_HISTORY('CM 2 Total','Zile CAS', 1))) )
if (v_z_i = 0 and v_z_c = 0) then
(v_z_i = greatest(0, to_number(ELEMENT_HISTORY('CM 1 Total','Zile INTR', 1)))
v_z_c = greatest(0, to_number(ELEMENT_HISTORY('CM 1 Total','Zile CAS', 1))) )
v_zile_acordate_intr = v_z_i
v_zile_acordate_cas = v_z_c)
)

if (ELEMENT_NAME = 'CM 2') then


(v_zile_spital_acord_intr = CM_2_ZILE_SPITALIZARE_INTR_ASG_ITD
v_zile_spital_acord_cas = CM_2_ZILE_SPITALIZARE_CAS_ASG_ITD
v_zile_acordate_intr = CM_2_ZILE_INTR_ASG_ITD
v_zile_acordate_cas = CM_2_ZILE_CAS_ASG_ITD

if (v_in_continuare = 'D') then


(v_zile_acordate_intr = CM_1_TOTAL_ZILE_INTR_ASG_MONTH
v_zile_acordate_cas = CM_1_TOTAL_ZILE_CAS_ASG_MONTH)
)

if (ELEMENT_NAME = 'CM 3') then


(v_zile_spital_acord_intr = CM_3_ZILE_SPITALIZARE_INTR_ASG_ITD
v_zile_spital_acord_cas = CM_3_ZILE_SPITALIZARE_CAS_ASG_ITD
v_zile_acordate_intr = CM_3_ZILE_INTR_ASG_ITD
v_zile_acordate_cas = CM_3_ZILE_CAS_ASG_ITD

if (v_in_continuare = 'D') then


(v_zile_acordate_intr = CM_2_TOTAL_ZILE_INTR_ASG_MONTH
v_zile_acordate_cas = CM_2_TOTAL_ZILE_CAS_ASG_MONTH)
)

if (ELEMENT_NAME = 'CM 4') then


(v_zile_spital_acord_intr = CM_4_ZILE_SPITALIZARE_INTR_ASG_ITD
v_zile_spital_acord_cas = CM_4_ZILE_SPITALIZARE_CAS_ASG_ITD
v_zile_acordate_intr = CM_4_ZILE_INTR_ASG_ITD
v_zile_acordate_cas = CM_4_ZILE_CAS_ASG_ITD

if (v_in_continuare = 'D') then


(v_zile_acordate_intr = CM_3_TOTAL_ZILE_INTR_ASG_MONTH
v_zile_acordate_cas = CM_3_TOTAL_ZILE_CAS_ASG_MONTH)
)

if (ELEMENT_NAME = 'CM 5') then


(v_zile_spital_acord_intr = CM_5_ZILE_SPITALIZARE_INTR_ASG_ITD
v_zile_spital_acord_cas = CM_5_ZILE_SPITALIZARE_CAS_ASG_ITD
v_zile_acordate_intr = CM_5_ZILE_INTR_ASG_ITD
v_zile_acordate_cas = CM_5_ZILE_CAS_ASG_ITD

if (v_in_continuare = 'D') then


(v_zile_acordate_intr = CM_4_TOTAL_ZILE_INTR_ASG_MONTH
v_zile_acordate_cas = CM_4_TOTAL_ZILE_CAS_ASG_MONTH)
)
/* corectii */
v_zile_de_cor = 'N'
if
/* CM initial */
(v_data_inceput_CM >= PAY_PROC_PERIOD_START_DATE and
v_data_inceput_CM <= PAY_PROC_PERIOD_END_DATE) and
/* zile de corectat */
(v_zile_acordate_intr <> 0 or v_zile_acordate_cas <> 0) and
/* CM in continuare = 'N' */
v_in_continuare = 'N' then
(v_zile_de_cor = 'Y'
v_cm_sfarsit_zile_intr = v_zile_acordate_intr
v_cm_sfarsit_zile_cas = v_zile_acordate_cas
v_zile_acordate_intr = 0
v_zile_acordate_cas = 0)
/* End: corectii */
/* --------------------------------------------------------------------------------
End: zile deja acordate
-------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------
MEDIE ZILNICA CM
----------------------------------------------------------------------------------
mod de calcul:
1 = Medie zilnica CM 6 luni intregi
2 = Medie zilnica CM 5 luni intregi si 2 fractiuni de luna
*/
v_mod_calcul_medie_zilnica_cm = 1 /* CASS */
if CZ = '2' then
v_mod_calcul_medie_zilnica_cm = 2 /* CAS */

/* ----------------------------------------------
Medie zilnica CM se introduce manual
----------------------------------------------*/
v_medie_zilnica_cm = MED_COR
if (TIP_BOALA = '10' or TIP_BOALA = '11') then Bcli = MED_COR
if
/* CM incepe in luna curenta */
( (PAY_PROC_PERIOD_START_DATE <= v_data_inceput_CM) and
(v_data_inceput_CM <= PAY_PROC_PERIOD_END_DATE) ) and
/* media nu a fost introdusa manual */
(MED_COR = -77) and
/* CM initial */
(v_in_continuare = 'N')
then
/* ------------------------------------------------------------------------
daca nu s-a introdus, atunci se calculeaza media zilnica cm
------------------------------------------------------------------------ */
( /* N 1 */

/* ----------------------
dupa 01/01/2004
----------------------- */
if (TB = 'CC' and
DATA_INCEPUT_CM >= to_date('01/01/2004','DD/MM/YYYY') ) then
v_medie_zilnica_cm =
round(SAL_MEDIU_ECONOMIE / (CM_ORE_LUCRATOARE_LUNA_ASG_MONTH / 8), 2)
else /* ---------------------
alte tipuri boala
---------------------- */
( /* N 1-1 */

/* ----------------------------------
Stagiul de cotizare
------------------------------------*/
v_stagiu_cotizare = 1
v_stagiu_cotizare_minim = 6 /* Y 6 luni in ultimele 12 luni */

v_zl = v_zl_1+v_zl_2+v_zl_3+v_zl_4+v_zl_5+v_zl_6

v_zc =
v_zc_1+v_zc_2+v_zc_3+v_zc_4+v_zc_5+v_zc_6+v_zc_7+v_zc_8+v_zc_9+v_zc_10+v_zc_11+v_zc_12

/* N conditii de stagiu de cotizare */

/* Y [ 0, 6 ] luni in ultimele 12 luni */


if (TB = '02' or TB = '03' or TB = '04' or TB = '05' or TB = '06' or TB = '12' or TB = '10' or TB = '11' or
TB = '14' or TB = '15' or TB = '22' or TB = '23' or TB = '24') then
(
if (0 < v_zc and v_zc < v_zl) then
v_stagiu_cotizare_minim = 1 /* Y ( 0, 6 ) luni in ultimele 12 luni */

if (v_zc = 0) then
v_stagiu_cotizare_minim = 0 /* Y 0 luni in ultimele 12 luni */
)

/* Y conditii de stagiu de cotizare */


if (TB = '01' or TB = '07' or TB = '08' or TB = '09' or TB = '13' or TB = '16') then
(
if (v_zc < v_zl) or (v_zc = 0 and v_zl = 0) then
(v_stagiu_cotizare = 0
v_stagiu_cotizare_minim = -1) /* N [ 0, 6 ) luni in ultimele 12 luni */
)
/* ----------------------------------
End: Stagiul de cotizare
------------------------------------*/
/* ----------------------------------
medie zilnica cm se calculeaza
------------------------------------*/
/* -------------
Baza CM
--------------*/
if (v_stagiu_cotizare_minim = 6 or v_stagiu_cotizare_minim = 1 or v_stagiu_cotizare_minim = 0
or v_stagiu_cotizare_minim = -1) then
( /* N 1 */
v_max_aloc = 6
if (v_stagiu_cotizare_minim = 1 or v_stagiu_cotizare_minim = 0 or v_stagiu_cotizare_minim = -1) then
(
v_max_aloc = 0
if (v_zc_1 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_2 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_3 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_4 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_5 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_6 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_7 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_8 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_9 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_10 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_11 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_zc_12 <> 0) then v_max_aloc = v_max_aloc + 1
if (v_max_aloc > 6) then v_max_aloc = 6
)

v_p_1 = ' '


v_p_2 = ' '
v_p_3 = ' '
v_p_4 = ' '
v_p_5 = ' '
v_p_6 = ' '

v_z_1 = 0
v_z_2 = 0
v_z_3 = 0
v_z_4 = 0
v_z_5 = 0
v_z_6 = 0

v_v_1 = 0
v_v_2 = 0
v_v_3 = 0
v_v_4 = 0
v_v_5 = 0
v_v_6 = 0
v_nr_aloc = 0
v_6 = 0
v_z_6 = 0
if (V_VN_1 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_1 = 0) then
(v_p_1 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -1), 'MONTH')
v_z_1 = V_ZC_1
v_v_1 = V_VN_1))
if (V_VN_2 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_1 = 0) then
(v_p_1 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -2), 'MONTH')
v_z_1 = V_ZC_2
v_v_1 = V_VN_2) else
if (v_v_2 = 0) then
(v_p_2 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -2), 'MONTH')
v_z_2 = V_ZC_2
v_v_2 = V_VN_2))
if (V_VN_3 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_1 = 0) then
(v_p_1 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -3), 'MONTH')
v_z_1 = V_ZC_3
v_v_1 = V_VN_3) else
if (v_v_2 = 0) then
(v_p_2 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -3), 'MONTH')
v_z_2 = V_ZC_3
v_v_2 = V_VN_3) else
if (v_v_3 = 0) then
(v_p_3 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -3), 'MONTH')
v_z_3 = V_ZC_3
v_v_3 = V_VN_3))
if (V_VN_4 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_1 = 0) then
(v_p_1 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -4), 'MONTH')
v_z_1 = V_ZC_4
v_v_1 = V_VN_4) else
if (v_v_2 = 0) then
(v_p_2 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -4), 'MONTH')
v_z_2 = V_ZC_4
v_v_2 = V_VN_4) else
if (v_v_3 = 0) then
(v_p_3 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -4), 'MONTH')
v_z_3 = V_ZC_4
v_v_3 = V_VN_4) else
if (v_v_4 = 0) then
(v_p_4 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -4), 'MONTH')
v_z_4 = V_ZC_4
v_v_4 = V_VN_4))
if (V_VN_5 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_1 = 0) then
(v_p_1 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -5), 'MONTH')
v_z_1 = V_ZC_5
v_v_1 = V_VN_5) else
if (v_v_2 = 0) then
(v_p_2 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -5), 'MONTH')
v_z_2 = V_ZC_5
v_v_2 = V_VN_5) else
if (v_v_3 = 0) then
(v_p_3 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -5), 'MONTH')
v_z_3 = V_ZC_5
v_v_3 = V_VN_5) else
if (v_v_4 = 0) then
(v_p_4 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -5), 'MONTH')
v_z_4 = V_ZC_5
v_v_4 = V_VN_5) else
if (v_v_5 = 0) then
(v_p_5 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -5), 'MONTH')
v_z_5 = V_ZC_5
v_v_5 = V_VN_5))
if (V_VN_6 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_1 = 0) then
(v_p_1 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -6), 'MONTH')
v_z_1 = V_ZC_6
v_v_1 = V_VN_6) else
if (v_v_2 = 0) then
(v_p_2 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -6), 'MONTH')
v_z_2 = V_ZC_6
v_v_2 = V_VN_6) else
if (v_v_3 = 0) then
(v_p_3 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -6), 'MONTH')
v_z_3 = V_ZC_6
v_v_3 = V_VN_6) else
if (v_v_4 = 0) then
(v_p_4 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -6), 'MONTH')
v_z_4 = V_ZC_6
v_v_4 = V_VN_6) else
if (v_v_5 = 0) then
(v_p_5 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -6), 'MONTH')
v_z_5 = V_ZC_6
v_v_5 = V_VN_6) else
if (v_v_6 = 0) then
(v_p_6 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -6), 'MONTH')
v_z_6 = V_ZC_6
v_v_6 = V_VN_6
v_6 = 6))
if (V_VN_7 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_1 = 0) then
(v_p_1 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -7), 'MONTH')
v_z_1 = V_ZC_7
v_v_1 = V_VN_7) else
if (v_v_2 = 0) then
(v_p_2 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -7), 'MONTH')
v_z_2 = V_ZC_7
v_v_2 = V_VN_7) else
if (v_v_3 = 0) then
(v_p_3 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -7), 'MONTH')
v_z_3 = V_ZC_7
v_v_3 = V_VN_7) else
if (v_v_4 = 0) then
(v_p_4 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -7), 'MONTH')
v_z_4 = V_ZC_7
v_v_4 = V_VN_7) else
if (v_v_5 = 0) then
(v_p_5 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -7), 'MONTH')
v_z_5 = V_ZC_7
v_v_5 = V_VN_7) else
if (v_v_6 = 0) then
(v_p_6 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -7), 'MONTH')
v_z_6 = V_ZC_7
v_v_6 = V_VN_7
v_6 = 7))
if (V_VN_8 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_2 = 0) then
(v_p_2 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -8), 'MONTH')
v_z_2 = V_ZC_8
v_v_2 = V_VN_8) else
if (v_v_3 = 0) then
(v_p_3 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -8), 'MONTH')
v_z_3 = V_ZC_8
v_v_3 = V_VN_8) else
if (v_v_4 = 0) then
(v_p_4 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -8), 'MONTH')
v_z_4 = V_ZC_8
v_v_4 = V_VN_8) else
if (v_v_5 = 0) then
(v_p_5 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -8), 'MONTH')
v_z_5 = V_ZC_8
v_v_5 = V_VN_8) else
if (v_v_6 = 0) then
(v_p_6 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -8), 'MONTH')
v_z_6 = V_ZC_8
v_v_6 = V_VN_8
v_6 = 8))
if (V_VN_9 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_3 = 0) then
(v_p_3 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -9), 'MONTH')
v_z_3 = V_ZC_9
v_v_3 = V_VN_9) else
if (v_v_4 = 0) then
(v_p_4 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -9), 'MONTH')
v_z_4 = V_ZC_9
v_v_4 = V_VN_9) else
if (v_v_5 = 0) then
(v_p_5 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -9), 'MONTH')
v_z_5 = V_ZC_9
v_v_5 = V_VN_9) else
if (v_v_6 = 0) then
(v_p_6 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -9), 'MONTH')
v_z_6 = V_ZC_9
v_v_6 = V_VN_9
v_6 = 9))
if (V_VN_10 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_4 = 0) then
(v_p_4 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -10), 'MONTH')
v_z_4 = V_ZC_10
v_v_4 = V_VN_10) else
if (v_v_5 = 0) then
(v_p_5 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -10), 'MONTH')
v_z_5 = V_ZC_10
v_v_5 = V_VN_10) else
if (v_v_6 = 0) then
(v_p_6 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -10), 'MONTH')
v_z_6 = V_ZC_10
v_v_6 = V_VN_10
v_6 = 10))
if (V_VN_11 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_5 = 0) then
(v_p_5 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -11), 'MONTH')
v_z_5 = V_ZC_11
v_v_5 = V_VN_11) else
if (v_v_6 = 0) then
(v_p_6 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -11), 'MONTH')
v_z_6 = V_ZC_11
v_v_6 = V_VN_11
v_6 = 11))
if (V_VN_12 <> 0 and v_nr_aloc <= v_max_aloc) then
(v_nr_aloc = v_nr_aloc + 1
if (v_v_6 = 0) then
(v_p_6 = TO_TEXT(ADD_MONTHS(PAY_PROC_PERIOD_START_DATE, -12), 'MONTH')
v_z_6 = V_ZC_12
v_v_6 = V_VN_12
v_6 = 12))
) /* N 1 */
/* --------------------
End: Baza CM
---------------------*/

if ((v_mod_calcul_medie_zilnica_cm = 1) or
(PAY_PROC_PERIOD_START_DATE = v_data_inceput_CM))
then /* ------------------------------------------------
1 = Medie zilnica CM 6 luni intregi
------------------------------------------------ */
( /* N 1-1-1 */
v_perioada_1 = v_p_1
v_zile_contributive_1 = v_z_1
v_venituri_cm_1 = v_v_1
/* Y 0 luni in ultimele 12 luni */
if v_stagiu_cotizare_minim = 0 then
(
v_perioada_1 = TO_TEXT(PAY_PROC_PERIOD_START_DATE, 'MONTH')
v_zile_contributive_1 = CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH
v_venituri_cm_1 = CM_SALARIU_BAZA_LUNAR_ASG_MONTH
)

v_perioada_2 = v_p_2
v_zile_contributive_2 = v_z_2
v_venituri_cm_2 = v_v_2

v_perioada_3 = v_p_3
v_zile_contributive_3 = v_z_3
v_venituri_cm_3 = v_v_3

v_perioada_4 = v_p_4
v_zile_contributive_4 = v_z_4
v_venituri_cm_4 = v_v_4

v_perioada_5 = v_p_5
v_zile_contributive_5 = v_z_5
v_venituri_cm_5 = v_v_5

v_perioada_6 = v_p_6
v_zile_contributive_6 = v_z_6
v_venituri_cm_6 = v_v_6

v_perioada_7 = ' '


v_zile_contributive_7 = 0
v_venituri_cm_7 = 0
) /* N 1-1-1 */
/* END: 1 = Medie zilnica CM 6 luni intregi */

if ((v_mod_calcul_medie_zilnica_cm = 2) and
(PAY_PROC_PERIOD_START_DATE < v_data_inceput_CM))
then /* -------------------------------------------------------------------------
2 = Medie zilnica CM 5 luni intregi +2 fractiuni de luna
------------------------------------------------------------------------- */
( /* N 1-1-2 */
/* 1 fractiune de luna - in luna curenta */
/* ------------------------
CM zile + Venituri
------------------------ */
v_zc_0f =
GET_WORKING_DAYS( PAY_PROC_PERIOD_START_DATE, ADD_DAYS(v_data_inceput_CM, -1) )
/* cor
--------------- */
v_d_i = PAY_PROC_PERIOD_START_DATE /* data inceput */
v_d_s = ADD_DAYS(v_data_inceput_CM, -1) /* data sfarsit */
v_z = v_zc_0f /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: cor
--------------- */
v_zc_0f = v_z - v_CM_CFP /* TNN */
v_zl_0f = v_z

/* var */
v_vn_0f = CM_VENIT_VAR_ZI_ASG_MONTH *
(v_zc_0f - CM_ZILE_ASG_MONTH - v_CM_var)

/* var nelinar */
v_vn_0f = v_vn_0f + CM_VENIT_VARIABIL_NELINIAR_ZI_ASG_MONTH * v_CM_var

/* fix */
v_zc_fix = v_zc_0f
if (GET_TABLE_VALUE('CM perioada contributiva', 'Fel', '1')='P') then
v_zc_fix = v_zc_0f - CM_ZILE_ASG_MONTH

v_vn_0f = v_vn_0f + CM_VENIT_FIX_ZI_ASG_MONTH * v_zc_fix


/* Y 0 luni in ultimele 12 luni */
if v_stagiu_cotizare_minim = 0 then
(
v_vn_0f = 0
if CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH <> 0 then
v_vn_0f =
CM_SALARIU_BAZA_LUNAR_ASG_MONTH /
CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * (v_zc_0f - CM_ZILE_ASG_MONTH)
)

/* CM (alte CM decat cel curent) */


v_vn_0f = v_vn_0f + CM_INDEMNIZATIE_ASG_MONTH

/* plafonare */
v_plafon_p = (SAL_MEDIU_ECONOMIE * 5 / CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH ) *
v_zc_0f
/* depasire plafon */
if (v_plafon_p < v_vn_0f) then v_vn_0f = v_plafon_p

v_perioada_1 =
TO_TEXT(PAY_PROC_PERIOD_START_DATE, 'DD') +
' - ' + TO_TEXT(ADD_DAYS(v_data_inceput_CM, -1), 'DD') +
' ' + TO_TEXT(PAY_PROC_PERIOD_START_DATE, 'MONTH')
v_zile_contributive_1 = v_zc_0f
v_venituri_cm_1 = v_vn_0f
/* ------------------------------
end: CM zile + Venituri
------------------------------ */
/* END: 1 fractiune de luna - in luna curenta */

/* 2 fractiune de luna - in luna 6 */

v_data_inceput_6f = ADD_MONTHS(v_data_inceput_CM, -v_6)


dd = TO_NUMBER(to_text(v_data_inceput_CM, 'DD'))
mm = TO_NUMBER(to_text(v_data_inceput_CM, 'MM'))
if (dd = 30 and (mm = 4 or mm = 6 or mm = 9 or mm = 11)) then
v_data_inceput_6f =ADD_DAYS(v_data_inceput_6f, -1)
v_data_sfarsit_6f = LAST_DAY(ADD_MONTHS(v_data_inceput_CM, -v_6))
v_zc_6f = GET_WORKING_DAYS( v_data_inceput_6f, v_data_sfarsit_6f )

/* cor
------ */
v_d_i = v_data_inceput_6f /* data inceput */
v_d_s = v_data_sfarsit_6f /* data sfarsit */
v_z = v_zc_6f /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: cor
------------*/
if ((dd = 29 or dd = 30 or dd = 31) and mm = 8) then v_z = 0
v_zc_6f = v_z
if
/* putine zile contributive intr-o luna */
(v_zc_6f > v_z_6) then v_zc_6f = v_z_6
v_zl_6f = v_z

if (v_z_6 <> 0) then v_vn_6f = v_v_6 / v_z_6 * v_zc_6f else v_vn_6f = 0

v_perioada_7 = TO_TEXT(v_data_inceput_6f, 'DD') + ' - ' + TO_TEXT(v_data_sfarsit_6f, 'DD') +


' ' + TO_TEXT(v_data_sfarsit_6f, 'MONTH')
v_zile_contributive_7 = v_zc_6f
v_venituri_cm_7 = v_vn_6f
if (v_zc_6f = 0) then v_perioada_7 = ' '

/* END: 2 fractiune de luna - in luna 6 */

v_perioada_2 = v_p_1
v_zile_contributive_2 = v_z_1
v_venituri_cm_2 = v_v_1

v_perioada_3 = v_p_2
v_zile_contributive_3 = v_z_2
v_venituri_cm_3 = v_v_2

v_perioada_4 = v_p_3
v_zile_contributive_4 = v_z_3
v_venituri_cm_4 = v_v_3

v_perioada_5 = v_p_4
v_zile_contributive_5 = v_z_4
v_venituri_cm_5 = v_v_4

v_perioada_6 = v_p_5
v_zile_contributive_6 = v_z_5
v_venituri_cm_6 = v_v_5
v_zl = V_ZL_1 +V_ZL_2 + V_ZL_3 + V_ZL_4 + V_ZL_5 + V_ZL_0f + V_ZL_6f
) /* N 1-1-2 */
/* ---------------------------------------------------------------------------------
END: 2 = Medie zilnica CM 5 luni intregi +2 fractiuni de luna
--------------------------------------------------------------------------------- */

v_zile_contributive =
v_zile_contributive_1 + v_zile_contributive_2 + v_zile_contributive_3 +
v_zile_contributive_4 + v_zile_contributive_5 + v_zile_contributive_6 + v_zile_contributive_7

v_venituri_cm =
v_venituri_cm_1 + v_venituri_cm_2 + v_venituri_cm_3 +
v_venituri_cm_4 + v_venituri_cm_5 + v_venituri_cm_6 + v_venituri_cm_7
y_nr_p = 6
if (TB <> '00') then
(if (v_zile_contributive <> 0) then
(
if (GET_TABLE_VALUE('CM Baza lunara', 'Plafonare', '1')='D') then
( if (v_venituri_cm > (SAL_MEDIU_ECONOMIE * NR_SALARII_CAS) * y_nr_p) then
(
v_venituri_cm = (SAL_MEDIU_ECONOMIE * NR_SALARII_CAS) * y_nr_p

v_m1 = 'Notificare: ' + ELEMENT_NAME + ' Plafonare, CM Baza lunara = '


+ to_text(v_venituri_cm)
))

v_medie_zilnica_CM = round(v_venituri_cm / v_zile_contributive, 6) * v_stagiu_cotizare


)
else
v_medie_zilnica_CM = 0)

/* CM 10 +11
-------------- */
if (TB = '10' or TB = '16' or TB = '11') then
( MNTZ = round(v_zl / 6, 2)
yZL = MNTZ
if CZ = '2' then yZL = CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH
Bcli = 0
if v_stagiu_cotizare = 1 then
Bcli = round(v_venituri_cm / v_zile_contributive * yZL, 6) )
) /* N 1-1 */
/* --------------------------
End: alte tipuri boala
-------------------------- */

) /* N 1 */
/* -----------------------------------------
End: calculeaza media zilnica cm
----------------------------------------- */
/* CM in continuare
---------------------------*/
if (CZ = '2') or (CZ = '1' and DATA_INCEPUT_CM >= to_date('01/02/2006','DD/MM/YYYY')) then
( /* CAS */

if (v_data_inceput_CM < PAY_PROC_PERIOD_START_DATE) and


/* media a fost calculata in CM initial si transmisa prin balanta */
(MED <> -77) then
(v_medie_zilnica_CM = MED
if
/* corectie */
(MED <> MED_e) then v_medie_zilnica_CM = MED_e)

if (v_data_inceput_CM < PAY_PROC_PERIOD_START_DATE) and


/* medie preluata prin elem_history */
(TB = '10' or TB = '16' or TB = '11') then
(Bcli = MED_e)

if (v_in_continuare = 'D') then


if (TB = '10' or TB = '16' or TB = '11')
then Bcli = MED
else v_medie_zilnica_CM = MED

) /* end: CAS */

/* End: CM in continuare
---------------------------*/

if (TB = 'CC' and


DATA_INCEPUT_CM >= to_date('01/01/2004','DD/MM/YYYY') ) then
v_medie_zilnica_cm =
round(SAL_MEDIU_ECONOMIE / (CM_ORE_LUCRATOARE_LUNA_ASG_MONTH / 8), 6)

/* CM anterior
--------------------*/
if (v_data_inceput_CM < PAY_PROC_PERIOD_START_DATE or v_in_continuare = 'D') and
/* media este transmisa in CM anterior */
(MED_ANT <> -77) then v_medie_zilnica_CM = MED_ANT
/* End: CM anterior
-------------------- */

if (TB = '00') then v_medie_zilnica_CM = 0

/* -----------------------------------------------------------------------------------------------------
end: MEDIE ZILNICA CM
-----------------------------------------------------------------------------------------------------*/
/* -------------------------------------------------------------
initializare variabile pentru calcul zile totale pe CM
---------------------------------------------------------------*/
v_zile_spitalizare_intr = 0
v_zile_spitalizare_cas = 0
v_zile_intr = 0
v_zile_cas = 0

v_i_cm = v_data_inceput_CM
if (v_in_continuare = 'D') then v_i_cm = v_d_i_cm
i_cm = DAYS_BETWEEN( v_i_cm, to_date('01/01/2004','DD/MM/YYYY') )
/* --------------------------------
END: initializare variabile
-------------------------------- */
/* -------------------------------------------------------------------------
initializare variabile pentru calcul zile acordate in luna curenta
----------------------------------------------------------------------------*/
v_zile_spital_acord_intr_luna = 0
v_zile_spital_acord_cas_luna = 0
v_zile_acordate_intr_luna = 0
v_zile_acordate_cas_luna = 0
/* ------------------------------
END: initializare variabile
--------------------------------*/
/* ----------------------------------------------------------------
calculez data de separatie intre zile INTR si zile CAS
----------------------------------------------------------------*/
/* CM suportat de INTR si CAS */
v_d_17 = ADD_DAYS(v_i_cm,16)
if (TB = '02' or TB = '03' or TB = '04' or TB = '22' or TB = '23' or TB = '24') then
v_d_17 = ADD_DAYS(v_i_cm,2)
/* CM suportat numai de INTR */
if (TB = '00') then v_d_17 = ADD_DAYS(v_data_sfarsit_CM, 1) /* premisa */
/* CM suportat numai de CAS */
if (TB = '07') then v_d_17 = ADD_DAYS(v_i_cm, -1)
if (TB = '08') then v_d_17 = ADD_DAYS(v_i_cm, -1)
if (TB = '09') then v_d_17 = ADD_DAYS(v_i_cm, -1)
if (TB = '10') then v_d_17 = ADD_DAYS(v_i_cm, -1)
if (TB = '16') then v_d_17 = ADD_DAYS(v_i_cm, -1)
if (TB = '11') then v_d_17 = ADD_DAYS(v_i_cm, -1)
if (TB = 'CC') then v_d_17 = ADD_DAYS(v_i_cm, -1)
if (TB = '15') then v_d_17 = ADD_DAYS(v_i_cm, -1)
/* -------------------------------------
End: calculez data de separatie
------------------------------------- */
/* --------------------
zile totale pe CM
---------------------
v_zile_spitalizare_intr
v_zile_spitalizare_cas
v_zile_intr
v_zile_cas
*/
/*****caz 1*****/
/*
--+------------------+---------+--
i_CM d_17 s_CM
*/
if ( v_i_cm <= v_d_17 ) and ( v_d_17 <= v_data_sfarsit_CM ) then
(
/* v_zile_spitalizare_intr = 0 */
/* v_zile_spitalizare_cas = 0 */
v_zile_intr = GET_WORKING_DAYS(v_i_cm,v_d_17)

/* cor
------- */
v_d_i = v_i_cm /* data inceput */
v_d_s = v_d_17 /* data sfarsit */
v_z = v_zile_intr /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: cor
-------------*/
v_zile_intr = v_z

v_zile_cas = GET_WORKING_DAYS(ADD_DAYS(v_d_17,1),v_data_sfarsit_CM)

/* cor
------ */
v_d_i = ADD_DAYS(v_d_17,1) /* data inceput */
v_d_s = v_data_sfarsit_CM /* data sfarsit */
v_z = v_zile_cas /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: cor
-----------*/
v_zile_cas = v_z

/*****caz 2 ****/
/* numai zile CAS
--+--------------+----------------------+--
d_17 i_CM s_CM
*/
if (v_d_17 < v_i_cm) and ( v_d_17 < v_data_sfarsit_CM ) then
(
/* v_zile_spitalizare_intr = 0 */
/* v_zile_spitalizare_cas */
/* v_zile_intr = 0 */
v_zile_cas = GET_WORKING_DAYS(ADD_DAYS(v_d_17,1),v_data_sfarsit_CM)
/* cor
-----*/
v_d_i = ADD_DAYS(v_d_17,1) /* data inceput */
v_d_s = v_data_sfarsit_CM /* data sfarsit */
v_z = v_zile_cas /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: cor
------------*/
v_zile_cas = v_z
)
/*****caz 3****/
/* numai zile INTR
--+----------+----------+--
i_CM s_CM d_17
*/
if ( v_i_cm < v_d_17 ) and ( v_data_sfarsit_CM < v_d_17 ) then
(
/* v_zile_spitalizare_intr = 0 */
/* v_zile_spitalizare_cas = 0 */
v_zile_intr = GET_WORKING_DAYS(v_i_cm, v_data_sfarsit_CM)
/* cor
----- */
v_d_i = v_i_cm /* data inceput */
v_d_s = v_data_sfarsit_CM /* data sfarsit */
v_z = v_zile_intr /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: cor
------------*/
v_zile_intr = v_z

/* v_zile_cas = 0 */
)
/* ---------------------------
End: zile totale pe CM
----------------------------*/
/* ------------------------------
zile totale in luna curenta
-------------------------------
intersectez CM cu luna curenta pt a obtine
zile lucratoare de CM din luna curenta
*/
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE,v_i_cm)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE,v_data_sfarsit_CM)
v_zile_lucratoare_crt = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* cor
------------ */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_lucratoare_crt /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: cor
------------*/
v_zile_lucratoare_crt = v_z

/* -------------------------------------
End: zile totale in luna curenta
-------------------------------------- */
/* -----------------------------------------------------------
zile ce mai pot fi acordate: Zile CM din luna
----------------------------------------------------------- */
v_zile_spitalizare_intr_crt = v_zile_spitalizare_intr - v_zile_spital_acord_intr
v_zile_spitalizare_cas_crt = v_zile_spitalizare_cas - v_zile_spital_acord_cas
v_zile_intr_crt = v_zile_intr - v_zile_acordate_intr
v_zile_cas_crt = v_zile_cas - v_zile_acordate_cas
if ( v_zile_spitalizare_intr_crt > 0 ) and ( v_zile_lucratoare_crt > 0 ) then
( v_zile_spital_acord_intr_luna = least(v_zile_spitalizare_intr_crt, v_zile_lucratoare_crt)
v_zile_lucratoare_crt = v_zile_lucratoare_crt - v_zile_spital_acord_intr_luna )
if ( v_zile_spitalizare_cas_crt > 0 ) and ( v_zile_lucratoare_crt > 0 ) then
( v_zile_spital_acord_cas_luna = least(v_zile_spitalizare_cas_crt, v_zile_lucratoare_crt)
v_zile_lucratoare_crt = v_zile_lucratoare_crt - v_zile_spital_acord_cas_luna )
if ( v_zile_intr_crt > 0 ) and ( v_zile_lucratoare_crt > 0 ) then
( v_zile_acordate_intr_luna = least(v_zile_intr_crt, v_zile_lucratoare_crt)
v_zile_lucratoare_crt = v_zile_lucratoare_crt - v_zile_acordate_intr_luna )
if ( v_zile_cas_crt > 0 ) and ( v_zile_lucratoare_crt > 0 ) then
( v_zile_acordate_cas_luna = least(v_zile_cas_crt, v_zile_lucratoare_crt)
v_zile_lucratoare_crt = v_zile_lucratoare_crt - v_zile_acordate_cas_luna )
/* -----------------------------------------------------------
End: zile ce mai pot fi acordate: Zile CM din luna
----------------------------------------------------------- */
/* ------------------------------------------------
CM corectii inlocuieste calcul automat
------------------------------------------------- */
if (ELEMENT_NAME = 'CM 1') then
(if (CM_1_CORECTII_ZILE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_intr_luna = CM_1_CORECTII_ZILE_INTR_ENTRY_VALUE
if (CM_1_CORECTII_ZILE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_cas_luna = CM_1_CORECTII_ZILE_CAS_ENTRY_VALUE)

if (ELEMENT_NAME = 'CM 2') then


(if (CM_2_CORECTII_ZILE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_intr_luna = CM_2_CORECTII_ZILE_INTR_ENTRY_VALUE
if (CM_2_CORECTII_ZILE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_cas_luna = CM_2_CORECTII_ZILE_CAS_ENTRY_VALUE)

if (ELEMENT_NAME = 'CM 3') then


(if (CM_3_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_spital_acord_intr_luna = CM_3_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE
if (CM_3_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_spital_acord_cas_luna = CM_3_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE
if (CM_3_CORECTII_ZILE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_intr_luna = CM_3_CORECTII_ZILE_INTR_ENTRY_VALUE
if (CM_3_CORECTII_ZILE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_cas_luna = CM_3_CORECTII_ZILE_CAS_ENTRY_VALUE)

if (ELEMENT_NAME = 'CM 4') then


(if (CM_4_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_spital_acord_intr_luna = CM_4_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE
if (CM_4_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_spital_acord_cas_luna = CM_4_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE
if (CM_4_CORECTII_ZILE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_intr_luna = CM_4_CORECTII_ZILE_INTR_ENTRY_VALUE
if (CM_4_CORECTII_ZILE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_cas_luna = CM_4_CORECTII_ZILE_CAS_ENTRY_VALUE)

if (ELEMENT_NAME = 'CM 5') then


(if (CM_5_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_spital_acord_intr_luna = CM_5_CORECTII_ZILE_SPITALIZARE_INTR_ENTRY_VALUE
if (CM_5_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_spital_acord_cas_luna = CM_5_CORECTII_ZILE_SPITALIZARE_CAS_ENTRY_VALUE
if (CM_5_CORECTII_ZILE_INTR_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_intr_luna = CM_5_CORECTII_ZILE_INTR_ENTRY_VALUE
if (CM_5_CORECTII_ZILE_CAS_ENTRY_VALUE was not defaulted ) then
v_zile_acordate_cas_luna = CM_5_CORECTII_ZILE_CAS_ENTRY_VALUE)
/* ----------------------------------------------------------------
End: CM corectii inlocuieste calcul automat
---------------------------------------------------------------- */
/* ----------------------------------------------------------------------------
reactualizam total zile acordate din fiecare tip in parte
---------------------------------------------------------------------------- */
v_zile_spital_acord_intr = v_zile_spital_acord_intr + v_zile_spital_acord_intr_luna
v_zile_spital_acord_cas = v_zile_spital_acord_cas + v_zile_spital_acord_cas_luna
v_zile_acordate_intr = v_zile_acordate_intr + v_zile_acordate_intr_luna
v_zile_acordate_cas = v_zile_acordate_cas + v_zile_acordate_cas_luna
/* ----------------------------------------------------------------------------
End: reactualizam total zile acordate din fiecare tip in parte
---------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------
Total zile INTR si CAS ce au fost acordate in luna curenta
------------------------------------------------------------------------ */
v_zile_total_intr = v_zile_spital_acord_intr_luna + v_zile_acordate_intr_luna
v_zile_total_cas = v_zile_spital_acord_cas_luna + v_zile_acordate_cas_luna
/* ------------------------------------------
End: calc Total zile INTR si CAS
------------------------------------------- */
/* -----------------------
CM inceput
-----------------------*/
if
(
/* CM incepe in luna curenta */
( (PAY_PROC_PERIOD_START_DATE <= v_data_inceput_CM) and
(v_data_inceput_CM <= PAY_PROC_PERIOD_END_DATE) ) or
/* CM anterior */
( (v_data_inceput_CM < PAY_PROC_PERIOD_START_DATE) and
/* media este transmisa in CM anterior */
(MED_ANT <> -77) ) or
/* corectii la necesitate */
( (PAY_PROC_PERIOD_START_DATE <= v_data_inceput_CM and
v_data_inceput_CM <= PAY_PROC_PERIOD_END_DATE) and
(MED <> -77) )
) and
/* continuare in lunile urmatoare */
(v_data_sfarsit_CM >= PAY_PROC_PERIOD_END_DATE)
then
/* genereaza CM inceput */
v_cm_inceput_medie_zilnica = v_medie_zilnica_CM - MED
/* -----------------------
End: CM inceput
-----------------------*/
/* -----------------------
CM sfarsit
----------------------- */
if (v_data_sfarsit_CM < PAY_PROC_PERIOD_END_DATE) or
(GET_TABLE_VALUE('CM in continuare', 'Element', '1')='D' and
v_data_sfarsit_CM = PAY_PROC_PERIOD_END_DATE ) then
(v_stop = ELEMENT_NAME + ' Stop'
if (MED <> -77) then v_cm_sfarsit_medie_zilnica = MED
v_cm_sfarsit_zile_spitalizare_intr = v_zile_spital_acord_intr
v_cm_sfarsit_zile_spitalizare_cas = v_zile_spital_acord_cas
if (v_zile_de_cor = 'Y')
then
(v_cm_sfarsit_zile_intr = v_cm_sfarsit_zile_intr + v_zile_acordate_intr
v_cm_sfarsit_zile_cas = v_cm_sfarsit_zile_cas + v_zile_acordate_cas)
else
(v_cm_sfarsit_zile_intr = v_zile_acordate_intr
v_cm_sfarsit_zile_cas = v_zile_acordate_cas) )
/* --------------------------
End: CM sfarsit
-------------------------- */
return
/* CM [nr] luna*/
v_zile_spital_acord_intr_luna,
v_zile_spital_acord_cas_luna,
v_zile_acordate_intr_luna,
v_zile_acordate_cas_luna,
v_zile_total_intr, /* CM [nr] Zile */
v_zile_total_cas, /* CM [nr] Zile */
TIP_BOALA,
v_data_inceput_CM,
v_data_sfarsit_CM,
v_medie_zilnica_cm, /* CM [nr] Total */
v_zile_contributive, /* Baza CM Zile */
v_venituri_cm, /* Baza CM Venituri */
v_stagiu_cotizare,
Bcli, /* CM [nr] Total */
v_stop,
v_m1,
/* CM [nr] Total */
v_zile_acordate_intr,
v_zile_acordate_cas,
v_i_cm,
i_cm,
/* CM inceput */
v_cm_inceput_medie_zilnica,
/* CM sfarsit */
v_cm_sfarsit_medie_zilnica,
v_cm_sfarsit_zile_spitalizare_intr,
v_cm_sfarsit_zile_spitalizare_cas,
v_cm_sfarsit_zile_intr,
v_cm_sfarsit_zile_cas,
/* CM baza */
v_perioada_1,
v_perioada_2,
v_perioada_3,
v_perioada_4,
v_perioada_5,
v_perioada_6,
v_perioada_7,
v_zile_contributive_1,
v_zile_contributive_2,
v_zile_contributive_3,
v_zile_contributive_4,
v_zile_contributive_5,
v_zile_contributive_6,
v_zile_contributive_7,
v_venituri_cm_1,
v_venituri_cm_2,
v_venituri_cm_3,
v_venituri_cm_4,
v_venituri_cm_5,
v_venituri_cm_6,
v_venituri_cm_7,
/* CM Suspendare contract */
v_lansare_suspendare,
v_data_inceperii,
v_data_incheierii,
v_cod_indemnizatie
/* End: Formula: CM */

CM_08

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CM_08 */

default for CM_Total is 0

default for Zile_Total is 0

default for CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH is 0

default for CM_SALARIU_BAZA_LUNAR_ASG_MONTH is 0

/* contractul colectiv de munca nu prevede compensatia */

default for COMPENSATIE_INDEMNIZATIE_MATERNITATE is 'N'

default for ASG_NUMBER is ' '

inputs are

CM_Total,

Zile_Total

/* -----------------------------------------------------------------------------------------------
CM Compensatie indemnizatie maternitate

------------------------------------------------------------------------------------------------ */

/*

art. 66 din Contractul de Munc nr. 1116/2003:

In cazul n care salariata se afl n concediu de maternitate,

unitatea va compensa, diferena dintre salariul de baz i indemnizaia legal

concediu de maternitate >> cod indemnizatie boala = 08 Sarcina si lehuzie

*/

if

/* contractul colectiv prevede acordarea compensatiei */

(COMPENSATIE_INDEMNIZATIE_MATERNITATE = 'Y') then

/* Compensatie = ( Salariu de baz brut lunar / Nr. de zile lucrtoare din lun *

zile de concediu de maternitate compensate din luna ) - Indemnizaia de materniate */

x = round((CM_SALARIU_BAZA_LUNAR_ASG_MONTH /

CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * Zile_Total) - CM_Total, -3)

if ( x > 0 )

/* se acorda compensatie */

then (v_cm_compensatie = x

v_fel = GET_LOOKUP_MEANING('RO_HR_CM_COMPENSATIE', '10'))

/* nu se acorda compensatie >> se emite un mesaj de notificare */

else v_m1 = 'Notificare: ' + ELEMENT_NAME + ' CM Compensatie = ' + to_text(x) + ' NU se acorda '

)
/* ------------------------------------------------------------------------------------------------

End: CM Compensatie indemnizatie maternitate

------------------------------------------------------------------------------------------------ */

return

v_cm_compensatie,

v_fel,

v_m1

/* End: Formula: CM_08 */

CM_CFP

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CM_CFP */

/* Concediu Fara Plata */

default for FP_ZI_1_ASG_RUN is 0

default for FP_ZI_2_ASG_RUN is 0

default for FP_ZI_3_ASG_RUN is 0

default for FP_ZI_4_ASG_RUN is 0

default for FP_ZI_5_ASG_RUN is 0

default for FP_ZI_6_ASG_RUN is 0

default for FP_ZI_7_ASG_RUN is 0


default for FP_ZI_8_ASG_RUN is 0

default for FP_ZI_9_ASG_RUN is 0

default for FP_ZI_10_ASG_RUN is 0

default for FP_ZI_11_ASG_RUN is 0

default for FP_ZI_12_ASG_RUN is 0

default for FP_ZI_13_ASG_RUN is 0

default for FP_ZI_14_ASG_RUN is 0

default for FP_ZI_15_ASG_RUN is 0

default for FP_ZI_16_ASG_RUN is 0

default for FP_ZI_17_ASG_RUN is 0

default for FP_ZI_18_ASG_RUN is 0

default for FP_ZI_19_ASG_RUN is 0

default for FP_ZI_20_ASG_RUN is 0

default for FP_ZI_21_ASG_RUN is 0

default for FP_ZI_22_ASG_RUN is 0

default for FP_ZI_23_ASG_RUN is 0

default for FP_ZI_24_ASG_RUN is 0

default for FP_ZI_25_ASG_RUN is 0

default for FP_ZI_26_ASG_RUN is 0

default for FP_ZI_27_ASG_RUN is 0

default for FP_ZI_28_ASG_RUN is 0

default for FP_ZI_29_ASG_RUN is 0

default for FP_ZI_30_ASG_RUN is 0

default for FP_ZI_31_ASG_RUN is 0

/* Absenta Nemotivata */

default for AN_ZI_1_ASG_RUN is 0

default for AN_ZI_2_ASG_RUN is 0

default for AN_ZI_3_ASG_RUN is 0


default for AN_ZI_4_ASG_RUN is 0

default for AN_ZI_5_ASG_RUN is 0

default for AN_ZI_6_ASG_RUN is 0

default for AN_ZI_7_ASG_RUN is 0

default for AN_ZI_8_ASG_RUN is 0

default for AN_ZI_9_ASG_RUN is 0

default for AN_ZI_10_ASG_RUN is 0

default for AN_ZI_11_ASG_RUN is 0

default for AN_ZI_12_ASG_RUN is 0

default for AN_ZI_13_ASG_RUN is 0

default for AN_ZI_14_ASG_RUN is 0

default for AN_ZI_15_ASG_RUN is 0

default for AN_ZI_16_ASG_RUN is 0

default for AN_ZI_17_ASG_RUN is 0

default for AN_ZI_18_ASG_RUN is 0

default for AN_ZI_19_ASG_RUN is 0

default for AN_ZI_20_ASG_RUN is 0

default for AN_ZI_21_ASG_RUN is 0

default for AN_ZI_22_ASG_RUN is 0

default for AN_ZI_23_ASG_RUN is 0

default for AN_ZI_24_ASG_RUN is 0

default for AN_ZI_25_ASG_RUN is 0

default for AN_ZI_26_ASG_RUN is 0

default for AN_ZI_27_ASG_RUN is 0

default for AN_ZI_28_ASG_RUN is 0

default for AN_ZI_29_ASG_RUN is 0

default for AN_ZI_30_ASG_RUN is 0

default for AN_ZI_31_ASG_RUN is 0


default for DURATA_NORMALA_TIMP_LUCRU is 8

default for Data_inceput_CM is '01-FEB-1900' (date)

inputs are

Data_inceput_CM

v_zi = TO_NUMBER(to_text(Data_inceput_CM, 'DD'))

x0 = 0

x1 = x0 + (FP_ZI_1_ASG_RUN + AN_ZI_1_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x2 = x1 + (FP_ZI_2_ASG_RUN + AN_ZI_2_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x3 = x2 + (FP_ZI_3_ASG_RUN + AN_ZI_3_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x4 = x3 + (FP_ZI_4_ASG_RUN + AN_ZI_4_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x5 = x4 + (FP_ZI_5_ASG_RUN + AN_ZI_5_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x6 = x5 + (FP_ZI_6_ASG_RUN + AN_ZI_6_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x7 = x6 + (FP_ZI_7_ASG_RUN + AN_ZI_7_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x8 = x7 + (FP_ZI_8_ASG_RUN + AN_ZI_8_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x9 = x8 + (FP_ZI_9_ASG_RUN + AN_ZI_9_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x10 = x9 + (FP_ZI_10_ASG_RUN + AN_ZI_10_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x11 = x10 + (FP_ZI_11_ASG_RUN + AN_ZI_11_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x12 = x11 + (FP_ZI_12_ASG_RUN + AN_ZI_12_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x13 = x12 + (FP_ZI_13_ASG_RUN + AN_ZI_13_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x14 = x13 + (FP_ZI_14_ASG_RUN + AN_ZI_14_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x15 = x14 + (FP_ZI_15_ASG_RUN + AN_ZI_15_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x16 = x15 + (FP_ZI_16_ASG_RUN + AN_ZI_16_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x17 = x16 + (FP_ZI_17_ASG_RUN + AN_ZI_17_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU


x18 = x17 + (FP_ZI_18_ASG_RUN + AN_ZI_18_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x19 = x18 + (FP_ZI_19_ASG_RUN + AN_ZI_19_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x20 = x19 + (FP_ZI_20_ASG_RUN + AN_ZI_20_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x21 = x20 + (FP_ZI_21_ASG_RUN + AN_ZI_21_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x22 = x21 + (FP_ZI_22_ASG_RUN + AN_ZI_22_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x23 = x22 + (FP_ZI_23_ASG_RUN + AN_ZI_23_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x24 = x23 + (FP_ZI_24_ASG_RUN + AN_ZI_24_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x25 = x24 + (FP_ZI_25_ASG_RUN + AN_ZI_25_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x26 = x25 + (FP_ZI_26_ASG_RUN + AN_ZI_26_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x27 = x26 + (FP_ZI_27_ASG_RUN + AN_ZI_27_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x28 = x27 + (FP_ZI_28_ASG_RUN + AN_ZI_28_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x29 = x28 + (FP_ZI_29_ASG_RUN + AN_ZI_29_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

x30 = x29 + (FP_ZI_30_ASG_RUN + AN_ZI_30_ASG_RUN) / DURATA_NORMALA_TIMP_LUCRU

if (v_zi = 1) then v_CFP_zile = x0 else

if (v_zi = 2) then v_CFP_zile = x1 else

if (v_zi = 3) then v_CFP_zile = x2 else

if (v_zi = 4) then v_CFP_zile = x3 else

if (v_zi = 5) then v_CFP_zile = x4 else

if (v_zi = 6) then v_CFP_zile = x5 else

if (v_zi = 7) then v_CFP_zile = x6 else

if (v_zi = 8) then v_CFP_zile = x7 else

if (v_zi = 9) then v_CFP_zile = x8 else

if (v_zi = 10) then v_CFP_zile = x9 else

if (v_zi = 11) then v_CFP_zile = x10 else

if (v_zi = 12) then v_CFP_zile = x11 else

if (v_zi = 13) then v_CFP_zile = x12 else

if (v_zi = 14) then v_CFP_zile = x13 else


if (v_zi = 15) then v_CFP_zile = x14 else

if (v_zi = 16) then v_CFP_zile = x15 else

if (v_zi = 17) then v_CFP_zile = x16 else

if (v_zi = 18) then v_CFP_zile = x17 else

if (v_zi = 19) then v_CFP_zile = x18 else

if (v_zi = 20) then v_CFP_zile = x19 else

if (v_zi = 21) then v_CFP_zile = x20 else

if (v_zi = 22) then v_CFP_zile = x21 else

if (v_zi = 23) then v_CFP_zile = x22 else

if (v_zi = 24) then v_CFP_zile = x23 else

if (v_zi = 25) then v_CFP_zile = x24 else

if (v_zi = 26) then v_CFP_zile = x25 else

if (v_zi = 27) then v_CFP_zile = x26 else

if (v_zi = 28) then v_CFP_zile = x27 else

if (v_zi = 29) then v_CFP_zile = x28 else

if (v_zi = 30) then v_CFP_zile = x29 else

if (v_zi = 31) then v_CFP_zile = x30

v_CONCEDII_zile = 0

/* NU calculeaza */

if (GET_TABLE_VALUE('CM venit variabil neliniar', 'Calcul', '1')='N') then v_CONCEDII_zile = 0

return

/* CM [nr] CFP */

v_CFP_zile,

v_CONCEDII_zile

/* End: Formula: CM_CFP */


CM_COMPENSATIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CM_COMPENSATIE */

/* CM Compensatie */
default for Suma is 0

default for PROCENT_CN_ASG_MONTH is 0


default for PROCENT_CD_ASG_MONTH is 0
default for PROCENT_CS_ASG_MONTH is 0
default for ORE_CN_ASG_MONTH is 0
default for ORE_CD_ASG_MONTH is 0
default for ORE_CS_ASG_MONTH is 0
/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0
default for ROT is 0

inputs are Suma

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3

/* -------------------------------
Conditii de munca
------------------------------- */
baza = Suma
procent_cd = PROCENT_CD_ASG_MONTH
procent_cs = PROCENT_CS_ASG_MONTH

if v_cond_m = 1 then v_cs = baza


if v_cond_m = 2 then v_cd = baza
if v_cond_m = 3 then v_cn = baza

if ORE_CN_ASG_MONTH <> 0
then
(
v_cd = round(baza * procent_cd / 100, ROT)
v_cs = round(baza * procent_cs / 100, ROT)
v_cn = baza - (v_cd + v_cs)
)
else if ORE_CD_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
v_cd = baza - (v_cs)
)
else if ORE_CS_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
)
/* -------------------------------
End: Conditii de munca
------------------------------- */

if (Suma <> 0) then v_suma = Suma

return
Suma,
v_cn, /*CN*/
v_cd,
v_cs,

/* Conta CM Compensatie */
v_suma

/* End: Formula: CM_COMPENSATIE */

CM_INCEPUT

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CM_INCEPUT */

default for ELEMENT_NAME is ' '

/* CM anterior

-----------------------------------------------------------------------------------------------------*/

default for CM_1_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0

default for CM_1_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0

default for CM_1_ANTERIOR_ZILE_INTR_ENTRY_VALUE is 0

default for CM_1_ANTERIOR_ZILE_CAS_ENTRY_VALUE is 0


default for CM_2_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0

default for CM_2_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0

default for CM_2_ANTERIOR_ZILE_INTR_ENTRY_VALUE is 0

default for CM_2_ANTERIOR_ZILE_CAS_ENTRY_VALUE is 0

default for CM_3_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0

default for CM_3_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0

default for CM_3_ANTERIOR_ZILE_INTR_ENTRY_VALUE is 0

default for CM_3_ANTERIOR_ZILE_CAS_ENTRY_VALUE is 0

default for CM_4_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0

default for CM_4_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0

default for CM_4_ANTERIOR_ZILE_INTR_ENTRY_VALUE is 0

default for CM_4_ANTERIOR_ZILE_CAS_ENTRY_VALUE is 0

default for CM_5_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE is 0

default for CM_5_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE is 0

default for CM_5_ANTERIOR_ZILE_INTR_ENTRY_VALUE is 0

default for CM_5_ANTERIOR_ZILE_CAS_ENTRY_VALUE is 0

If (ELEMENT_NAME = 'CM 1 inceput') Then

v_cm_inceput_zile_spitalizare_intr =

CM_1_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE

v_cm_inceput_zile_spitalizare_cas =

CM_1_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE

v_cm_inceput_zile_intr =

CM_1_ANTERIOR_ZILE_INTR_ENTRY_VALUE
v_cm_inceput_zile_cas =

CM_1_ANTERIOR_ZILE_CAS_ENTRY_VALUE

If (ELEMENT_NAME = 'CM 2 inceput') Then

v_cm_inceput_zile_spitalizare_intr =

CM_2_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE

v_cm_inceput_zile_spitalizare_cas =

CM_2_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE

v_cm_inceput_zile_intr =

CM_2_ANTERIOR_ZILE_INTR_ENTRY_VALUE

v_cm_inceput_zile_cas =

CM_2_ANTERIOR_ZILE_CAS_ENTRY_VALUE

If (ELEMENT_NAME = 'CM 3 inceput') Then

v_cm_inceput_zile_spitalizare_intr =

CM_3_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE

v_cm_inceput_zile_spitalizare_cas =

CM_3_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE

v_cm_inceput_zile_intr =

CM_3_ANTERIOR_ZILE_INTR_ENTRY_VALUE

v_cm_inceput_zile_cas =

CM_3_ANTERIOR_ZILE_CAS_ENTRY_VALUE

If (ELEMENT_NAME = 'CM 4 inceput') Then

v_cm_inceput_zile_spitalizare_intr =
CM_4_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE

v_cm_inceput_zile_spitalizare_cas =

CM_4_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE

v_cm_inceput_zile_intr =

CM_4_ANTERIOR_ZILE_INTR_ENTRY_VALUE

v_cm_inceput_zile_cas =

CM_4_ANTERIOR_ZILE_CAS_ENTRY_VALUE

If (ELEMENT_NAME = 'CM 5 inceput') Then

v_cm_inceput_zile_spitalizare_intr =

CM_5_ANTERIOR_ZILE_SPITALIZARE_INTR_ENTRY_VALUE

v_cm_inceput_zile_spitalizare_cas =

CM_5_ANTERIOR_ZILE_SPITALIZARE_CAS_ENTRY_VALUE

v_cm_inceput_zile_intr =

CM_5_ANTERIOR_ZILE_INTR_ENTRY_VALUE

v_cm_inceput_zile_cas =

CM_5_ANTERIOR_ZILE_CAS_ENTRY_VALUE

return

/* CM inceput */

v_cm_inceput_zile_spitalizare_intr,

v_cm_inceput_zile_spitalizare_cas,

v_cm_inceput_zile_intr,

v_cm_inceput_zile_cas

/* End: Formula: CM_INCEPUT */


CM_INDEMNIZATIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CM_INDEMNIZATIE */

default for CM_INDEMNIZATIE_ASG_MONTH is 0


default for TOTAL_PRESTATII_ZILE_ASG_MONTH is 0
default for PROCENT_CN_ASG_MONTH is 0
default for PROCENT_CD_ASG_MONTH is 0
default for PROCENT_CS_ASG_MONTH is 0
default for ORE_CN_ASG_MONTH is 0
default for ORE_CD_ASG_MONTH is 0
default for ORE_CS_ASG_MONTH is 0
/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0
default for ROT is 0

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3

v_cm_indemnizatie = CM_INDEMNIZATIE_ASG_MONTH
v_Zile = TOTAL_PRESTATII_ZILE_ASG_MONTH

/* -------------------------------
Conditii de munca
------------------------------- */
baza = v_cm_indemnizatie
procent_cd = PROCENT_CD_ASG_MONTH
procent_cs = PROCENT_CS_ASG_MONTH

if v_cond_m = 1 then v_cs = baza


if v_cond_m = 2 then v_cd = baza
if v_cond_m = 3 then v_cn = baza

if ORE_CN_ASG_MONTH <> 0
then
(
v_cd = round(baza * procent_cd / 100, ROT)
v_cs = round(baza * procent_cs / 100, ROT)
v_cn = baza - (v_cd + v_cs)
)
else if ORE_CD_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
v_cd = baza - (v_cs)
)
else if ORE_CS_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
)
/* -------------------------------
End: Conditii de munca
------------------------------- */

return
v_cm_indemnizatie,
v_Zile,
v_cn, /*CN*/
v_cd,
v_cs

/* End: Formula: CM_INDEMNIZATIE */

CM_INDEMNIZATIE

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CM_INDEMNIZATIE */

default for CM_INDEMNIZATIE_ASG_MONTH is 0

default for TOTAL_PRESTATII_ZILE_ASG_MONTH is 0

v_cm_indemnizatie = CM_INDEMNIZATIE_ASG_MONTH

v_Zile = TOTAL_PRESTATII_ZILE_ASG_MONTH

return

v_cm_indemnizatie,

v_Zile
/* End: Formula: CM_INDEMNIZATIE */

CM_LUNA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CM_LUNA (vs. 01 jan 2006) */

/* CM luna */
default for DATA_INCEPUT_CM is '01-FEB-1900' (date)
default for DATA_SFARSIT_SPITALIZARE is '01-FEB-1900' (date)
default for DATA_SFARSIT_CM is '01-FEB-1900' (date)
default for ZILE_SPITALIZARE_INTR is 0
default for ZILE_SPITALIZARE_CAS is 0
default for ZILE_INTR is 0
default for ZILE_CAS is 0
default for MEDIE_ZILNICA_CM is 0
default for TIP_BOALA is '00'
default for Bcli is 0
default for Stagiu_cotizare is 0
/* End: CM luna */

default for ELEMENT_NAME is ' '


default for CM_SALARIU_BAZA_ORAR_ASG_MONTH is 0
default for CM_SALARIU_BAZA_LUNAR_ASG_MONTH is 0
default for CM_SPORURI_NEGOCIATE_PROCENTE_ASG_MONTH is 0
default for DURATA_NORMALA_TIMP_LUCRU is 8
default for PRIME_ASG_MONTH is 0
default for PR_MEDIU_VENITURI_ASG_PTD is 0
default for CM_ORE_LUCRATOARE_LUNA_ASG_MONTH is 0
default for CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH is 0
default for SANATATE_ASIGURAT is 0
default for ASG_HOURS is 0
default for SAL_MEDIU_ECONOMIE is 0
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2000' (DATE)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2000' (DATE)
default for NR_SALARII_CAS is 5 /* 5 */
default for CAS_ASIGURAT is 0 /* 9.5 */

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT_CM,
DATA_SFARSIT_SPITALIZARE,
DATA_SFARSIT_CM,
TIP_BOALA,

ZILE_SPITALIZARE_INTR,
ZILE_SPITALIZARE_CAS,
ZILE_INTR,
ZILE_CAS,
MEDIE_ZILNICA_CM,
Bcli,
Stagiu_cotizare

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

eff_date = PAY_PROC_PERIOD_START_DATE
SMIN = to_number(GET_TABLE_VALUE('Sal min economie', 'Valoare', '1', eff_date))

TB = TIP_BOALA
CZ = '1'
if (TB = '02' or TB = '03' or TB = '04' or TB = '22' or TB = '23' or TB = '24' or TB = '10' or TB = '11') then
CZ = '2'

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

/* CM indexare
Trimestrial, prin hotarare a guvernului se stabileste
procentul de indexare al CM */
v_CM_PROCENT_INDEXARE = to_number(GET_TABLE_VALUE('CM procent indexare', 'Procent', '1'))

v_CM_DATA_INDEXARE = to_date(GET_TABLE_VALUE('CM data indexare', 'Data', '1') , 'DD-MM-YY')


/* End: CM indexare */

v_data_inceput_CM = DATA_INCEPUT_CM
v_data_sfarsit_CM = DATA_SFARSIT_CM

v_medie_zilnica_cm = MEDIE_ZILNICA_CM
if (GET_TABLE_VALUE('CM Indemnizatie lunara', 'Plafonare', '1')='D' and CZ = '2') then
( /* N 1 */
if (CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * MEDIE_ZILNICA_CM >
SAL_MEDIU_ECONOMIE * NR_SALARII_CAS) then
(
v_medie_zilnica_cm = (SAL_MEDIU_ECONOMIE * NR_SALARII_CAS) /
CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH

v_m1 = 'Notificare: ' + ELEMENT_NAME + ' Plafonare Indemnizatie, Media = '


+ to_text(v_medie_zilnica_cm)
)
) /* N 1 */

v_procent_boala = 0
v_cm_CAS = 0
v_suma_cm = 0
v_cm_intreprindere = 0
v_spital_intreprindere = 0
v_spital_cas = 0

if (TIP_BOALA = '00') then v_procent_boala = 0


if (TIP_BOALA = '01') then v_procent_boala = 75
if (TIP_BOALA = '02') then v_procent_boala = 80
if (TIP_BOALA = '22') then v_procent_boala = 100 /* FS 80% */
if (TIP_BOALA = '03') then v_procent_boala = 80
if (TIP_BOALA = '23') then v_procent_boala = 100 /* FS 80% */
if (TIP_BOALA = '04') then v_procent_boala = 80
if (TIP_BOALA = '24') then v_procent_boala = 100 /* FS 80% */
if (TIP_BOALA = '05') then v_procent_boala = 100
if (TIP_BOALA = '06') then v_procent_boala = 100
if (TIP_BOALA = '07') then v_procent_boala = 75
if (TIP_BOALA = '08') then v_procent_boala = 85
if (TIP_BOALA = '09') then v_procent_boala = 85
if (TIP_BOALA = '10') then v_procent_boala = 25
if (TIP_BOALA = '16') then v_procent_boala = 25

if (TIP_BOALA = '11') then v_procent_boala = 25


if (TIP_BOALA = '12') then v_procent_boala = 100

if (TIP_BOALA = '13') then v_procent_boala =75


if (TIP_BOALA = '14') then v_procent_boala = 100
if (TIP_BOALA = '15') then v_procent_boala = 75
if (TIP_BOALA = 'CC') then v_procent_boala = 85

v_urgenta = 'N'
if TIP_BOALA = '06' then v_urgenta = 'D'

/* -----------------------------------------------------------------------------------------------
CM indexare
------------------------------------------------------------------------------------------------*/

/* data legala de indexare


CM_DATA_INDEXARE */
/* a 91-a zi de concediu medical */
v_d_91 = ADD_DAYS(v_data_inceput_CM,90)
/* -------------------------------------------------------------
Se indexeaza numai daca a 91-a zi de CM se implineste
in luna legiferata de indexare sau inainte
-------------------------------------------------------------- */
v_data_acordare_indexare = greatest(V_CM_DATA_INDEXARE, v_d_91)
if (v_d_91 > V_CM_DATA_INDEXARE)
then
v_data_acordare_indexare = ADD_YEARS(v_data_acordare_indexare, 400)

v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE,v_data_inceput_CM)


v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE,v_data_sfarsit_CM)
v_indexare = 'No'
/* conditia de timp */
if
/* data_acordare_indexare este in luna curenta */
(v_data_inceput <= v_data_acordare_indexare and
v_data_acordare_indexare <= v_data_sfarsit) then
(
v_indexare = 'Yes'

/* zile neindexate */
v_zile_neindexate =
GET_WORKING_DAYS(PAY_PROC_PERIOD_START_DATE,
ADD_DAYS(v_data_acordare_indexare, -1))

/* zile indexate */
v_zile_indexate = ZILE_CAS - v_zile_neindexate
)

if
/* data_acordare_indexare este in perioada anterioara */
(v_data_acordare_indexare <= v_data_inceput) then
(
v_indexare = 'Yes'

/* zile neindexate */
v_zile_neindexate = 0

/* numai zile indexate */


v_zile_indexate = ZILE_CAS
)
/* End: conditia de timp */
/* ------------------------------------------------------------------------------------------------
End:CM indexare
------------------------------------------------------------------------------------------------*/
/* -----------------------------------------------------------------------------------------------
calcul CM [ numai ZILE_CAS = v_zile_indexate + v_zile_neindexate ]
----------------------------------------------------------------------------------------------- */
if (TIP_BOALA = '10' or TIP_BOALA = '16' or TIP_BOALA = '11')
then
( /* N 1 */
if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
(Bcli1 = round(Bcli / CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * ZILE_CAS, 6)
Bmax = roundup((v_procent_boala / 100) * Bcli1, 1)

S1 = round( (CM_SALARIU_BAZA_ORAR_ASG_MONTH / 10000 *


(1 + CM_SPORURI_NEGOCIATE_PROCENTE_ASG_MONTH / 100) ) *
((v_procent_boala / 100) * v_durata_muncii) * (ZILE_CAS), 4)

C1 = roundup(Bcli1 - S1, 1)
if (C1 < Bmax) then v_suma_cm = S1 else v_suma_cm = Bmax )
else
(
Bcli1 = round(Bcli / CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * ZILE_CAS, 0)
Bmax = round((v_procent_boala / 100) * Bcli1, 0)

/* venitul salarial brut realizat de asigurat */


S1 = round( CM_SALARIU_BAZA_LUNAR_ASG_MONTH *
(1 + CM_SPORURI_NEGOCIATE_PROCENTE_ASG_MONTH / 100)
/ CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH
* (1-v_procent_boala / 100) * ZILE_CAS, 0)

C1 = round(Bcli1 - S1, 0)
/* cuantum indemnizatie nu poate fi negativ */
if C1 < 0 then
(
v_m1 = 'Notificare: ' + ELEMENT_NAME + ' C1 = ' + to_text(C1) + ' se face C1 = 0'
C1 = 0
)

v_suma_cm = least(C1, Bmax)


)
) /* N 1 */

v_pr_intr = v_procent_boala
/* anulare tratare diferentiata 2006-04-12
if (TB = '22' or TB = '23' or TB = '24') then v_pr_intr = 80 */

if (v_urgenta = 'N' )
then
/* v_urgenta = 'N' */
(
if not (TIP_BOALA = '10' or TIP_BOALA = '16' or TIP_BOALA = '11') then
(if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_suma_cm = roundup((v_procent_boala / 100) *
(ZILE_INTR + ZILE_CAS) *
v_medie_zilnica_cm,1)
else
v_suma_cm = round((v_pr_intr / 100) * (ZILE_INTR) * v_medie_zilnica_cm +
(v_procent_boala / 100) * (ZILE_CAS) * v_medie_zilnica_cm, 0) )
if
/* conditia de timp */
(v_indexare = 'Yes') then
(/* N 1 */
/* conditia de plafon (si altele) poate anula indexarea */
if not ( ( v_suma_cm <=
SAL_MEDIU_ECONOMIE / CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * ZILE_CAS
and TIP_BOALA = 'CC' and
v_data_inceput_CM < to_date('01/01/2004','DD/MM/YYYY') ) or
( v_suma_cm <= 3 * SAL_MEDIU_ECONOMIE and TIP_BOALA <> 'CC' ) )
then
(
v_zile_neindexate = v_zile_neindexate + v_zile_indexate
v_zile_indexate = 0
)
/* end: conditia de plafon */

if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )


then
(v_suma_cm_neindexata =
roundup((v_procent_boala / 100) * (ZILE_INTR + v_zile_neindexate) * v_medie_zilnica_cm,1)
v_suma_cm_indexata =
roundup((v_procent_boala / 100) * (v_zile_indexate) *
v_medie_zilnica_cm * (1 + V_CM_PROCENT_INDEXARE / 100),1) )
else
(v_suma_cm_neindexata =
round((v_pr_intr / 100) * (ZILE_INTR) * v_medie_zilnica_cm +
(v_procent_boala / 100) * (v_zile_neindexate) * v_medie_zilnica_cm,0)
v_suma_cm_indexata =
round((v_procent_boala / 100) * (v_zile_indexate) *
v_medie_zilnica_cm * (1 + V_CM_PROCENT_INDEXARE / 100),0) )
v_suma_cm = v_suma_cm_neindexata + v_suma_cm_indexata
) /* N 1 */

if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )


then
(v_spital_intreprindere = roundup((v_procent_boala / 100) *
(ZILE_SPITALIZARE_INTR ) *
V_MEDIE_ZILNICA_CM,1)
v_spital_cas = roundup((v_procent_boala / 100) *
(ZILE_SPITALIZARE_CAS ) *
V_MEDIE_ZILNICA_CM,1) )
else
(v_spital_intreprindere = round((v_procent_boala / 100) *
(ZILE_SPITALIZARE_INTR ) *
V_MEDIE_ZILNICA_CM,0)
v_spital_cas = round((v_procent_boala / 100) *
(ZILE_SPITALIZARE_CAS ) *
V_MEDIE_ZILNICA_CM,0) )
)
else
/* v_urgenta = 'Y' */
(
if not (TIP_BOALA = '10' or TIP_BOALA = '16' or TIP_BOALA = '11') then
(if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_suma_cm = roundup((v_procent_boala / 100) *
(ZILE_INTR + ZILE_CAS ) *
v_medie_zilnica_cm,1)
else
v_suma_cm = round((v_pr_intr / 100) * (ZILE_INTR) * v_medie_zilnica_cm +
(v_procent_boala / 100) * (ZILE_CAS ) * v_medie_zilnica_cm,0) )
if
/* conditia de timp */
(v_indexare = 'Yes') then
( /* N 2 */
/* conditia de plafon (si altele) poate anula indexarea */
if not ( ( v_suma_cm <=
SAL_MEDIU_ECONOMIE / CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * ZILE_CAS
and TIP_BOALA = 'CC' and
v_data_inceput_CM < to_date('01/01/2004','DD/MM/YYYY') ) or
( v_suma_cm <= 3 * SAL_MEDIU_ECONOMIE and TIP_BOALA <> 'CC' ) )
then
(
v_zile_neindexate = v_zile_neindexate + v_zile_indexate
v_zile_indexate = 0
)
/* end: conditia de plafon */

if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )


then
(v_suma_cm_neindexata =
roundup((v_procent_boala / 100) *
(ZILE_INTR + v_zile_neindexate) *
v_medie_zilnica_cm,1)
v_suma_cm_indexata =
roundup((v_procent_boala / 100) *
(ZILE_INTR + v_zile_indexate) *
v_medie_zilnica_cm * (1 + V_CM_PROCENT_INDEXARE / 100),1) )
else
(v_suma_cm_neindexata =
round((v_pr_intr / 100) * (ZILE_INTR) * v_medie_zilnica_cm +
(v_procent_boala / 100) * (v_zile_neindexate) * v_medie_zilnica_cm,0)
v_suma_cm_indexata =
round((v_pr_intr / 100) * (ZILE_INTR) *
v_medie_zilnica_cm * (1 + V_CM_PROCENT_INDEXARE / 100) +
(v_procent_boala / 100) * (v_zile_indexate) *
v_medie_zilnica_cm * (1 + V_CM_PROCENT_INDEXARE / 100),0) )
v_suma_cm = v_suma_cm_neindexata + v_suma_cm_indexata
) /* N 2 */

if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )


then
(v_suma_cm = v_suma_cm + roundup((100 / 100) *
(ZILE_SPITALIZARE_INTR + ZILE_SPITALIZARE_CAS) *
V_MEDIE_ZILNICA_CM,1)
v_spital_intreprindere = roundup((100 / 100) *
(ZILE_SPITALIZARE_INTR ) *
V_MEDIE_ZILNICA_CM,1)
v_spital_cas = roundup((100 / 100) *
(ZILE_SPITALIZARE_CAS ) *
V_MEDIE_ZILNICA_CM,1) )
else
(v_suma_cm = v_suma_cm + round((100 / 100) *
(ZILE_SPITALIZARE_INTR + ZILE_SPITALIZARE_CAS) *
V_MEDIE_ZILNICA_CM,0)
v_spital_intreprindere = round((100 / 100) *
(ZILE_SPITALIZARE_INTR ) *
V_MEDIE_ZILNICA_CM,0)
v_spital_cas = round((100 / 100) *
(ZILE_SPITALIZARE_CAS ) *
V_MEDIE_ZILNICA_CM,0) )
)
if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_cm_intreprindere = roundup((v_pr_intr / 100) * (ZILE_INTR) * V_MEDIE_ZILNICA_CM,1)
else
v_cm_intreprindere = round((v_pr_intr / 100) * (ZILE_INTR) * V_MEDIE_ZILNICA_CM,0)

v_cm_CAS = v_suma_cm - v_cm_intreprindere - v_spital_intreprindere - v_spital_cas

v_total_intreprindere = v_cm_intreprindere + v_spital_intreprindere

v_total_Bas = v_cm_CAS + v_spital_cas

v_total_cass = v_total_Bas
v_zile_cass = ZILE_SPITALIZARE_CAS + ZILE_CAS
if TB = '16' then v_zile_1_cass = (v_zile_cass * 2) / v_durata_muncii

if (TB = '02' or TB = '03' or TB = '04' or TB = '22' or TB = '23' or TB = '24' or TB = '10' or TB = '11') then
(
v_CM_AMBP = V_TOTAL_BAS
v_zile_AMBP = ZILE_SPITALIZARE_CAS + ZILE_CAS
if TB = '10' or TB = '11' then v_zile_1_AMBP = (v_zile_AMBP * 2) / v_durata_muncii
)

/* -----------------------------------------------------------------------------
Corelatia dintre ZILE si SUME

ZILE_INTR ----- v_cm_intreprindere


ZILE_CAS ------ v_cm_CAS (v_zile_indexate + v_zile_neindexate)
ZILE_SPITALIZARE_INTR ----- v_spital_intreprindere
ZILE_SPITALIZARE_CAS ------- v_spital_cas

Total ------- v_suma_cm

End: Corelatia dintre ZILE si SUME


---------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------------------------------
End: calcul CM
-------------------------------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------------------------
CM Compensatie
------------------------------------------------------------------------------------------------ */

v_calcul_compensatie_cm = 'No'
v_compensatie_cm = 0
if
(v_calcul_compensatie_cm = 'Yes')
then
( /* N 1 */
v_durata_muncii = ASG_HOURS

if ( v_durata_muncii > 8 ) then v_durata_muncii = 8

if (v_urgenta = 'N' and v_procent_boala < 100 and TIP_BOALA <> 'CC') then
(
v_cm_spital = v_spital_intreprindere + v_spital_cas

v_venit_spital = round((ZILE_SPITALIZARE_INTR + ZILE_SPITALIZARE_CAS) *


v_durata_muncii *
CM_SALARIU_BAZA_ORAR_ASG_MONTH *
(PR_MEDIU_VENITURI_ASG_PTD / 100), 0)

v_m1 = 'Notificare CM: v_cm_spital = ' + to_text(v_cm_spital) +


' v_venit_spital = ' + to_text(v_venit_spital)

if ( v_venit_spital > v_cm_spital ) then


v_compensatie_cm = v_venit_spital - v_cm_spital
)

if (TIP_BOALA = 'CC') then


(
v_cm_cc = v_suma_cm

v_venit_cc = round((ZILE_SPITALIZARE_CAS + ZILE_CAS) * v_durata_muncii *


CM_SALARIU_BAZA_ORAR_ASG_MONTH, 0)

v_m1 = 'Notificare CM: v_cm_cc = ' + to_text(v_cm_cc) +


' v_venit_cc = ' + to_text(v_venit_cc)

if ( v_venit_cc > v_cm_cc ) then


v_compensatie_cm = v_venit_cc - v_cm_cc
)
) /* N 1 */

/* ------------------------------------------------------------------------------------------------
End: CM Compensatie
------------------------------------------------------------------------------------------------ */

/* --------------------------
calcul CM Total
-------------------------- */

v_cm_total = v_suma_cm + v_compensatie_cm

/* --------------------------
End: calcul CM Total
-------------------------- */

/* ------------------------------------------------------------------
CM Contributie sanatate ; CAS
------------------------------------------------------------------ */

v_zile_cm =
ZILE_SPITALIZARE_INTR +
ZILE_SPITALIZARE_CAS +
ZILE_INTR +
ZILE_CAS
if CZ = '2' then
( /* N 1 */
v_z = v_zile_cm
if (TIP_BOALA = '10' or TIP_BOALA = '16' or TIP_BOALA = '11') then
v_z = roundup((v_zile_cm * 2) / v_durata_muncii, 0)

/* -------------------
sanatate
------------------- */
v_nr_salarii = 2
if
/* modificare pentru CC */
(TIP_BOALA = 'CC') then v_nr_salarii = 2 /* de la 1 dec 2004 */

if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )


then
v_contributie_sanatate_cm = Stagiu_cotizare *
round((v_nr_salarii * SMIN *
(SANATATE_ASIGURAT / 100)) /
(CM_ORE_LUCRATOARE_LUNA_ASG_MONTH / v_durata_muncii) * v_z, 4)
else
v_contributie_sanatate_cm = Stagiu_cotizare *
round((v_nr_salarii * SMIN *
(SANATATE_ASIGURAT / 100)) /
(CM_ORE_LUCRATOARE_LUNA_ASG_MONTH / v_durata_muncii) * v_z, 0)
) /* N 1 */
/* -------------------
End : sanatate
------------------- */
/* ------------------------------------------------------------------
End: CM Contributie sanatate ; CAS
------------------------------------------------------------------ */

v_lansare = ELEMENT_NAME

/* -------------------------------------------------------------------------------------------
calcul CM xx
-------------------------------------------------------------------------------------------
In FR se realizraza corespondenta
CM 1 luna >> CM 1 indemnizatie etc.
*/

if (TIP_BOALA = '01')
then
(
v_lansare_cm_01 = ELEMENT_NAME
v_CM_Total_01 = V_CM_TOTAL
v_CM_Intrep_01 = V_TOTAL_INTREPRINDERE
v_CM_CAS_01 = V_TOTAL_BAS
v_Zile_Total_01 = v_zile_cm
v_zile_intrep_01 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_01 = ZILE_SPITALIZARE_CAS + ZILE_CAS

v_procent_boala_01 = v_procent_boala

if v_zile_cas_01 > 0 then v_nr_cazuri_01 = 1


if (v_indexare = 'Yes') then
(v_zile_neindexate_01 = v_zile_neindexate
v_zile_indexate_01 = v_zile_indexate
v_suma_cm_neindexata_01 = v_suma_cm_neindexata
v_suma_cm_indexata_01 = v_suma_cm_indexata
v_d_91_01 = v_data_acordare_indexare)

return
/* CM x indemnizatie */
v_cm_total,
v_lansare,

/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM CASS */
V_TOTAL_CASS,
v_zile_cass,
v_zile_1_cass,

v_suma_cm,
v_compensatie_cm,
v_m1,
v_urgenta,

/* CM sanatate */
/* v_contributie_sanatate_cm, Conta CM sanatate */

/* CM 01 */
v_lansare_cm_01,
v_CM_Total_01,
v_CM_Intrep_01,
v_CM_CAS_01,
v_Zile_Total_01,
v_zile_cas_01,
v_zile_intrep_01,
v_nr_cazuri_01,
v_procent_boala_01,
v_zile_neindexate_01,
v_zile_indexate_01,
v_suma_cm_neindexata_01,
v_suma_cm_indexata_01,
v_d_91_01
)

if (TIP_BOALA = '02') then


(
v_lansare_cm_02 = ELEMENT_NAME
v_CM_Total_02 = V_CM_TOTAL
v_CM_Intrep_02 = V_TOTAL_INTREPRINDERE
v_CM_CAS_02 = V_TOTAL_BAS
v_Zile_Total_02 = v_zile_cm
v_zile_intrep_02 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_02 = ZILE_SPITALIZARE_CAS + ZILE_CAS

if v_zile_cas_02 > 0 then v_nr_cazuri_02 = 1


v_procent_boala_02 = v_procent_boala

if (v_indexare = 'Yes') then


(v_zile_neindexate_02 = v_zile_neindexate
v_zile_indexate_02 = v_zile_indexate
v_suma_cm_neindexata_02 = v_suma_cm_neindexata
v_suma_cm_indexata_02 = v_suma_cm_indexata
v_d_91_02 = v_data_acordare_indexare)

return
/* CM x indemnizatie */
v_cm_total,
v_lansare,

/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM CAS
V_TOTAL_CAS, */
/* Conta CM Fond risc si accidente */
v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

/* nefolosit */
v_suma_cm,
v_compensatie_cm,
v_m1,
v_urgenta,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* CM 02 */
v_lansare_cm_02,
v_CM_Total_02,
v_CM_Intrep_02,
v_CM_CAS_02,
v_Zile_Total_02,
v_zile_cas_02,
v_zile_intrep_02,
v_nr_cazuri_02,
v_procent_boala_02,
v_zile_neindexate_02,
v_zile_indexate_02,
v_suma_cm_neindexata_02,
v_suma_cm_indexata_02,
v_d_91_02
)

if (TIP_BOALA = '22') then


(
v_lansare_cm_22 = ELEMENT_NAME
v_CM_Total_22 = V_CM_TOTAL
v_CM_Intrep_22 = V_TOTAL_INTREPRINDERE
v_CM_CAS_22 = V_TOTAL_BAS
v_Zile_Total_22 = v_zile_cm
v_zile_intrep_22 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_22 = ZILE_SPITALIZARE_CAS + ZILE_CAS

if v_zile_cas_22 > 0 then v_nr_cazuri_22 = 1

v_procent_boala_22 = v_procent_boala

if (v_indexare = 'Yes') then


(v_zile_neindexate_22 = v_zile_neindexate
v_zile_indexate_22 = v_zile_indexate
v_suma_cm_neindexata_22 = v_suma_cm_neindexata
v_suma_cm_indexata_22 = v_suma_cm_indexata
v_d_91_22 = v_data_acordare_indexare)

return
/* CM x indemnizatie */
v_cm_total,
v_lansare,

/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM CAS
V_TOTAL_CAS, */
/* Conta CM Fond risc si accidente */
v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

/* nefolosit */
v_suma_cm,
v_compensatie_cm,
v_m1,
v_urgenta,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* CM 22 */
v_lansare_cm_22,
v_CM_Total_22,
v_CM_Intrep_22,
v_CM_CAS_22,
v_Zile_Total_22,
v_zile_cas_22,
v_zile_intrep_22,
v_nr_cazuri_22,
v_procent_boala_22,
v_zile_neindexate_22,
v_zile_indexate_22,
v_suma_cm_neindexata_22,
v_suma_cm_indexata_22,
v_d_91_22
)

if (TIP_BOALA = '03') then


(
v_lansare_cm_03 = ELEMENT_NAME
v_CM_Total_03 = V_CM_TOTAL
v_CM_Intrep_03 = V_TOTAL_INTREPRINDERE
v_CM_CAS_03 = V_TOTAL_BAS
v_Zile_Total_03 = v_zile_cm
v_zile_intrep_03 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_03 = ZILE_SPITALIZARE_CAS + ZILE_CAS

if v_zile_cas_03 > 0 then v_nr_cazuri_03 = 1

v_procent_boala_03 = v_procent_boala

if (v_indexare = 'Yes') then


(v_zile_neindexate_03 = v_zile_neindexate
v_zile_indexate_03 = v_zile_indexate
v_suma_cm_neindexata_03 = v_suma_cm_neindexata
v_suma_cm_indexata_03 = v_suma_cm_indexata
v_d_91_03 = v_data_acordare_indexare)

return
/* CM x indemnizatie */
v_cm_total,
v_lansare,

/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM Fond risc si accidente */
v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

/* nefolosit */
v_suma_cm,
v_compensatie_cm,
v_m1,
v_urgenta,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* CM 03 */
v_lansare_cm_03,
v_CM_Total_03,
v_CM_Intrep_03,
v_CM_CAS_03,
v_Zile_Total_03,
v_zile_cas_03,
v_zile_intrep_03,
v_nr_cazuri_03,
v_procent_boala_03,
v_zile_neindexate_03,
v_zile_indexate_03,
v_suma_cm_neindexata_03,
v_suma_cm_indexata_03,
v_d_91_03
)

if (TIP_BOALA = '23') then


(
v_lansare_cm_23 = ELEMENT_NAME
v_CM_Total_23 = V_CM_TOTAL
v_CM_Intrep_23 = V_TOTAL_INTREPRINDERE
v_CM_CAS_23 = V_TOTAL_BAS
v_Zile_Total_23 = v_zile_cm
v_zile_intrep_23 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_23 = ZILE_SPITALIZARE_CAS + ZILE_CAS

if v_zile_cas_23 > 0 then v_nr_cazuri_23 = 1

v_procent_boala_23 = v_procent_boala

if (v_indexare = 'Yes') then


(v_zile_neindexate_23 = v_zile_neindexate
v_zile_indexate_23 = v_zile_indexate
v_suma_cm_neindexata_23 = v_suma_cm_neindexata
v_suma_cm_indexata_23 = v_suma_cm_indexata
v_d_91_23 = v_data_acordare_indexare)

return
/* CM x indemnizatie */
v_cm_total,
v_lansare,

/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM Fond risc si accidente */
v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

/* nefolosit */
v_suma_cm,
v_compensatie_cm,
v_m1,
v_urgenta,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* CM 23 */
v_lansare_cm_23,
v_CM_Total_23,
v_CM_Intrep_23,
v_CM_CAS_23,
v_Zile_Total_23,
v_zile_cas_23,
v_zile_intrep_23,
v_nr_cazuri_23,
v_procent_boala_23,
v_zile_neindexate_23,
v_zile_indexate_23,
v_suma_cm_neindexata_23,
v_suma_cm_indexata_23,
v_d_91_23
)

if (TIP_BOALA = '04') then


(
v_lansare_cm_04 = ELEMENT_NAME
v_CM_Total_04 = V_CM_TOTAL
v_CM_Intrep_04 = V_TOTAL_INTREPRINDERE
v_CM_CAS_04 = V_TOTAL_BAS
v_Zile_Total_04 = v_zile_cm
v_zile_intrep_04 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_04 = ZILE_SPITALIZARE_CAS + ZILE_CAS

if v_zile_cas_04 > 0 then v_nr_cazuri_04 = 1

v_procent_boala_04 = v_procent_boala

if (v_indexare = 'Yes') then


(v_zile_neindexate_04 = v_zile_neindexate
v_zile_indexate_04 = v_zile_indexate
v_suma_cm_neindexata_04 = v_suma_cm_neindexata
v_suma_cm_indexata_04 = v_suma_cm_indexata
v_d_91_04 = v_data_acordare_indexare)

return
/* CM x indemnizatie */
v_cm_total,
v_lansare,

/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM Fond risc si accident */
v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

/* nefolosit */
v_suma_cm,
v_compensatie_cm,
v_m1,
v_urgenta,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* CM 04 */
v_lansare_cm_04,
v_CM_Total_04,
v_CM_Intrep_04,
v_CM_CAS_04,
v_Zile_Total_04,
v_zile_cas_04,
v_zile_intrep_04,
v_nr_cazuri_04,
v_procent_boala_04,
v_zile_neindexate_04,
v_zile_indexate_04,
v_suma_cm_neindexata_04,
v_suma_cm_indexata_04,
v_d_91_04
)

if (TIP_BOALA = '24') then


(
v_lansare_cm_24 = ELEMENT_NAME
v_CM_Total_24 = V_CM_TOTAL
v_CM_Intrep_24 = V_TOTAL_INTREPRINDERE
v_CM_CAS_24 = V_TOTAL_BAS
v_Zile_Total_24 = v_zile_cm
v_zile_intrep_24 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_24 = ZILE_SPITALIZARE_CAS + ZILE_CAS

if v_zile_cas_24 > 0 then v_nr_cazuri_24 = 1

v_procent_boala_24 = v_procent_boala

if (v_indexare = 'Yes') then


(v_zile_neindexate_24 = v_zile_neindexate
v_zile_indexate_24 = v_zile_indexate
v_suma_cm_neindexata_24 = v_suma_cm_neindexata
v_suma_cm_indexata_24 = v_suma_cm_indexata
v_d_91_24 = v_data_acordare_indexare)

return
/* CM x indemnizatie */
v_cm_total,
v_lansare,

/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM Fond risc si accident */
v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

/* nefolosit */
v_suma_cm,
v_compensatie_cm,
v_m1,
v_urgenta,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* CM 24 */
v_lansare_cm_24,
v_CM_Total_24,
v_CM_Intrep_24,
v_CM_CAS_24,
v_Zile_Total_24,
v_zile_cas_24,
v_zile_intrep_24,
v_nr_cazuri_24,
v_procent_boala_24,
v_zile_neindexate_24,
v_zile_indexate_24,
v_suma_cm_neindexata_24,
v_suma_cm_indexata_24,
v_d_91_24
)

if (TIP_BOALA = '05') then


(
v_lansare_cm_05 = ELEMENT_NAME
v_CM_Total_05 = V_CM_TOTAL
v_CM_Intrep_05 = V_TOTAL_INTREPRINDERE
v_CM_CAS_05 = V_TOTAL_BAS
v_Zile_Total_05 = v_zile_cm
v_zile_intrep_05 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_05 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_05 > 0 then
v_nr_cazuri_05 = 1

v_procent_boala_05 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_05 = v_zile_neindexate
v_zile_indexate_05 = v_zile_indexate
v_suma_cm_neindexata_05 = v_suma_cm_neindexata
v_suma_cm_indexata_05 = v_suma_cm_indexata
v_d_91_05 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/* v_contributie_sanatate_cm, Conta CM sanatate */

v_lansare_cm_05,
v_CM_Total_05,
v_CM_Intrep_05,
v_CM_CAS_05,
v_Zile_Total_05,
v_zile_cas_05,
v_zile_intrep_05,
v_nr_cazuri_05,
v_procent_boala_05,

v_zile_neindexate_05,
v_zile_indexate_05,
v_suma_cm_neindexata_05,
v_suma_cm_indexata_05,
v_d_91_05

if (TIP_BOALA = '06') then


(
v_lansare_cm_06 = ELEMENT_NAME
v_CM_Total_06 = V_CM_TOTAL
v_CM_Intrep_06 = V_TOTAL_INTREPRINDERE
v_CM_CAS_06 = V_TOTAL_BAS
v_Zile_Total_06 = v_zile_cm
v_zile_intrep_06 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_06 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_06 > 0 then
v_nr_cazuri_06 = 1

v_procent_boala_06 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_06 = v_zile_neindexate
v_zile_indexate_06 = v_zile_indexate
v_suma_cm_neindexata_06 = v_suma_cm_neindexata
v_suma_cm_indexata_06 = v_suma_cm_indexata
v_d_91_06 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
/* Conta CM CASS */
V_TOTAL_CASS,
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */

v_lansare_cm_06,
v_CM_Total_06,
v_CM_Intrep_06,
v_CM_CAS_06,
v_Zile_Total_06,
v_zile_cas_06,
v_zile_intrep_06,
v_nr_cazuri_06,
v_procent_boala_06,

v_zile_neindexate_06,
v_zile_indexate_06,
v_suma_cm_neindexata_06,
v_suma_cm_indexata_06,
v_d_91_06

if (TIP_BOALA = '07') then


(
v_lansare_cm_07 = ELEMENT_NAME
v_CM_Total_07 = V_CM_TOTAL
v_CM_Intrep_07 = V_TOTAL_INTREPRINDERE
v_CM_CAS_07 = V_TOTAL_BAS
v_Zile_Total_07 = v_zile_cm
v_zile_intrep_07 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_07 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_07 > 0 then
v_nr_cazuri_07 = 1

v_procent_boala_07 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_07 = v_zile_neindexate
v_zile_indexate_07 = v_zile_indexate
v_suma_cm_neindexata_07 = v_suma_cm_neindexata
v_suma_cm_indexata_07 = v_suma_cm_indexata
v_d_91_07 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
/* Conta CM CASS */
V_TOTAL_CASS,
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */
v_lansare_cm_07,
v_CM_Total_07,
v_CM_Intrep_07,
v_CM_CAS_07,
v_Zile_Total_07,
v_zile_cas_07,
v_zile_intrep_07,
v_nr_cazuri_07,
v_procent_boala_07,

v_zile_neindexate_07,
v_zile_indexate_07,
v_suma_cm_neindexata_07,
v_suma_cm_indexata_07,
v_d_91_07

if (TIP_BOALA = '08') then


(
v_lansare_cm_08 = ELEMENT_NAME
v_CM_Total_08 = V_CM_TOTAL
v_CM_Intrep_08 = V_TOTAL_INTREPRINDERE
v_CM_CAS_08 = V_TOTAL_BAS
v_Zile_Total_08 = v_zile_cm
v_zile_intrep_08 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_08 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_08 > 0 then
v_nr_cazuri_08 = 1

v_procent_boala_08 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_08 = v_zile_neindexate
v_zile_indexate_08 = v_zile_indexate
v_suma_cm_neindexata_08 = v_suma_cm_neindexata
v_suma_cm_indexata_08 = v_suma_cm_indexata
v_d_91_08 = v_data_acordare_indexare
)

return
/* CM x indemnizatie */
v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
/* Conta CM CASS */
V_TOTAL_CASS,
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */

/* CM 08 */
v_lansare_cm_08,
v_CM_Total_08,
v_CM_Intrep_08,
v_CM_CAS_08,
v_Zile_Total_08,
v_zile_cas_08,
v_zile_intrep_08,
v_nr_cazuri_08,
v_procent_boala_08,
v_zile_neindexate_08,
v_zile_indexate_08,
v_suma_cm_neindexata_08,
v_suma_cm_indexata_08,
v_d_91_08

if (TIP_BOALA = '09') then


(
v_lansare_cm_09 = ELEMENT_NAME
v_CM_Total_09 = V_CM_TOTAL
v_CM_Intrep_09 = V_TOTAL_INTREPRINDERE
v_CM_CAS_09 = V_TOTAL_BAS
v_Zile_Total_09 = v_zile_cm
v_zile_intrep_09 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_09 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_09 > 0 then
v_nr_cazuri_09 = 1

v_procent_boala_09 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_09 = v_zile_neindexate
v_zile_indexate_09 = v_zile_indexate
v_suma_cm_neindexata_09 = v_suma_cm_neindexata
v_suma_cm_indexata_09 = v_suma_cm_indexata
v_d_91_09 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */

v_lansare_cm_09,
v_CM_Total_09,
v_CM_Intrep_09,
v_CM_CAS_09,
v_Zile_Total_09,
v_zile_cas_09,
v_zile_intrep_09,
v_nr_cazuri_09,
v_procent_boala_09,

v_zile_neindexate_09,
v_zile_indexate_09,
v_suma_cm_neindexata_09,
v_suma_cm_indexata_09,
v_d_91_09

if (TIP_BOALA = '10') then


(
v_lansare_cm_10 = ELEMENT_NAME
v_CM_Total_10 = V_CM_TOTAL
v_CM_Intrep_10 = V_TOTAL_INTREPRINDERE
v_CM_CAS_10 = V_TOTAL_BAS
v_Zile_Total_10 = v_zile_cm
v_zile_intrep_10 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_10 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_10 > 0 then v_nr_cazuri_10 = 1

v_procent_boala_10 = v_procent_boala

if (v_indexare = 'Yes') then


(
v_zile_neindexate_10 = v_zile_neindexate
v_zile_indexate_10 = v_zile_indexate
v_suma_cm_neindexata_10 = v_suma_cm_neindexata
v_suma_cm_indexata_10 = v_suma_cm_indexata
v_d_91_10 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* Conta CM Fond risc si accident */


v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

v_lansare_cm_10,
v_CM_Total_10,
v_CM_Intrep_10,
v_CM_CAS_10,
v_Zile_Total_10,
v_zile_cas_10,
v_zile_intrep_10,
v_nr_cazuri_10,
v_procent_boala_10,

v_zile_neindexate_10,
v_zile_indexate_10,
v_suma_cm_neindexata_10,
v_suma_cm_indexata_10,
v_d_91_10
)

if (TIP_BOALA = '16') then


(
v_lansare_cm_16 = ELEMENT_NAME
v_CM_Total_16 = V_CM_TOTAL
v_CM_Intrep_16 = V_TOTAL_INTREPRINDERE
v_CM_CAS_16 = V_TOTAL_BAS
v_Zile_Total_16 = v_zile_cm
v_zile_intrep_16 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_16 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_16 > 0 then v_nr_cazuri_16 = 1

v_procent_boala_16 = v_procent_boala

if (v_indexare = 'Yes') then


(
v_zile_neindexate_16 = v_zile_neindexate
v_zile_indexate_16 = v_zile_indexate
v_suma_cm_neindexata_16 = v_suma_cm_neindexata
v_suma_cm_indexata_16 = v_suma_cm_indexata
v_d_91_16 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
v_contributie_sanatate_cm, /* Conta CM sanatate */

/* Conta CM Fond risc si accident */


v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

v_lansare_cm_16,
v_CM_Total_16,
v_CM_Intrep_16,
v_CM_CAS_16,
v_Zile_Total_16,
v_zile_cas_16,
v_zile_intrep_16,
v_nr_cazuri_16,
v_procent_boala_16,

v_zile_neindexate_16,
v_zile_indexate_16,
v_suma_cm_neindexata_16,
v_suma_cm_indexata_16,
v_d_91_16
)

if (TIP_BOALA = '11') then


(
v_lansare_cm_11 = ELEMENT_NAME
v_CM_Total_11 = V_CM_TOTAL
v_CM_Intrep_11 = V_TOTAL_INTREPRINDERE
v_CM_CAS_11 = V_TOTAL_BAS
v_Zile_Total_11 = v_zile_cm
v_zile_intrep_11 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_11 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_11 > 0 then
v_nr_cazuri_11 = 1

v_procent_boala_11 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_11 = v_zile_neindexate
v_zile_indexate_11 = v_zile_indexate
v_suma_cm_neindexata_11 = v_suma_cm_neindexata
v_suma_cm_indexata_11 = v_suma_cm_indexata
v_d_91_11 = v_data_acordare_indexare
)

return v_suma_cm,
/* Conta CM Intrep */
v_total_intreprindere,
/* Conta CM CAS
V_TOTAL_CAS, */
/* Conta CM Fond risc si accidente */
v_CM_AMBP,
v_zile_AMBP,
v_zile_1_AMBP,

v_compensatie_cm,
v_cm_total,
v_m1,
v_contributie_sanatate_cm, /* Conta CM sanatate */
v_urgenta,
v_lansare,

v_lansare_cm_11,
v_CM_Total_11,
v_CM_Intrep_11,
v_CM_CAS_11,
v_Zile_Total_11,
v_zile_cas_11,
v_zile_intrep_11,
v_nr_cazuri_11,
v_procent_boala_11,

v_zile_neindexate_11,
v_zile_indexate_11,
v_suma_cm_neindexata_11,
v_suma_cm_indexata_11,
v_d_91_11

if (TIP_BOALA = '12') then


(
v_lansare_cm_12 = ELEMENT_NAME
v_CM_Total_12 = V_CM_TOTAL
v_CM_Intrep_12 = V_TOTAL_INTREPRINDERE
v_CM_CAS_12 = V_TOTAL_BAS
v_Zile_Total_12 = v_zile_cm
v_zile_intrep_12 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_12 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_12 > 0 then
v_nr_cazuri_12 = 1

v_procent_boala_12 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_12 = v_zile_neindexate
v_zile_indexate_12 = v_zile_indexate
v_suma_cm_neindexata_12 = v_suma_cm_neindexata
v_suma_cm_indexata_12 = v_suma_cm_indexata
v_d_91_12 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */

v_lansare_cm_12,
v_CM_Total_12,
v_CM_Intrep_12,
v_CM_CAS_12,
v_Zile_Total_12,
v_zile_cas_12,
v_zile_intrep_12,
v_nr_cazuri_12,
v_procent_boala_12,

v_zile_neindexate_12,
v_zile_indexate_12,
v_suma_cm_neindexata_12,
v_suma_cm_indexata_12,
v_d_91_12

if (TIP_BOALA = '13') then


(
v_lansare_cm_13 = ELEMENT_NAME
v_CM_Total_13 = V_CM_TOTAL
v_CM_Intrep_13 = V_TOTAL_INTREPRINDERE
v_CM_CAS_13 = V_TOTAL_BAS
v_Zile_Total_13 = v_zile_cm
v_zile_intrep_13 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_13 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_13 > 0 then
v_nr_cazuri_13 = 1

v_procent_boala_13 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_13 = v_zile_neindexate
v_zile_indexate_13 = v_zile_indexate
v_suma_cm_neindexata_13 = v_suma_cm_neindexata
v_suma_cm_indexata_13 = v_suma_cm_indexata
v_d_91_13 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */

v_lansare_cm_13,
v_CM_Total_13,
v_CM_Intrep_13,
v_CM_CAS_13,
v_Zile_Total_13,
v_zile_cas_13,
v_zile_intrep_13,
v_nr_cazuri_13,
v_procent_boala_13,

v_zile_neindexate_13,
v_zile_indexate_13,
v_suma_cm_neindexata_13,
v_suma_cm_indexata_13,
v_d_91_13

if (TIP_BOALA = '14') then


(
v_lansare_cm_14 = ELEMENT_NAME
v_CM_Total_14 = V_CM_TOTAL
v_CM_Intrep_14 = V_TOTAL_INTREPRINDERE
v_CM_CAS_14 = V_TOTAL_BAS
v_Zile_Total_14 = v_zile_cm
v_zile_intrep_14 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_14 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_14 > 0 then
v_nr_cazuri_14 = 1

v_procent_boala_14 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_14 = v_zile_neindexate
v_zile_indexate_14 = v_zile_indexate
v_suma_cm_neindexata_14 = v_suma_cm_neindexata
v_suma_cm_indexata_14 = v_suma_cm_indexata
v_d_91_14 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */

v_lansare_cm_14,
v_CM_Total_14,
v_CM_Intrep_14,
v_CM_CAS_14,
v_Zile_Total_14,
v_zile_cas_14,
v_zile_intrep_14,
v_nr_cazuri_14,
v_procent_boala_14,

v_zile_neindexate_14,
v_zile_indexate_14,
v_suma_cm_neindexata_14,
v_suma_cm_indexata_14,
v_d_91_14

if (TIP_BOALA = '15') then


(
v_lansare_cm_15 = ELEMENT_NAME
v_CM_Total_15 = V_CM_TOTAL
v_CM_Intrep_15 = V_TOTAL_INTREPRINDERE
v_CM_CAS_15 = V_TOTAL_BAS
v_Zile_Total_15 = v_zile_cm
v_zile_intrep_15 = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_15 = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_15 > 0 then
v_nr_cazuri_15 = 1

v_procent_boala_15 = v_procent_boala

if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_15 = v_zile_neindexate
v_zile_indexate_15 = v_zile_indexate
v_suma_cm_neindexata_15 = v_suma_cm_neindexata
v_suma_cm_indexata_15 = v_suma_cm_indexata
v_d_91_15 = v_data_acordare_indexare
)

return v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
V_TOTAL_CASS, /* Conta CM CASS */
v_zile_cass,
v_zile_1_cass,
v_compensatie_cm,
v_cm_total,
v_m1,
v_urgenta,
v_lansare,

/* CM sanatate */
/*v_contributie_sanatate_cm, Conta CM sanatate */

v_lansare_cm_15,
v_CM_Total_15,
v_CM_Intrep_15,
v_CM_CAS_15,
v_Zile_Total_15,
v_zile_cas_15,
v_zile_intrep_15,
v_nr_cazuri_15,
v_procent_boala_15,

v_zile_neindexate_15,
v_zile_indexate_15,
v_suma_cm_neindexata_15,
v_suma_cm_indexata_15,
v_d_91_15

if (TIP_BOALA = 'CC') then


(
v_lansare_cm_cc = ELEMENT_NAME
v_CM_Total_cc = V_CM_TOTAL
v_CM_Intrep_cc = V_TOTAL_INTREPRINDERE
v_CM_CAS_cc = V_TOTAL_BAS
v_Zile_Total_cc = v_zile_cm
v_zile_intrep_cc = ZILE_SPITALIZARE_INTR + ZILE_INTR
v_zile_cas_cc = ZILE_SPITALIZARE_CAS + ZILE_CAS
if v_zile_cas_cc > 0 then
v_nr_cazuri_cc = 1

v_procent_boala_cc = v_procent_boala
if
(v_indexare = 'Yes')
then
(
v_zile_neindexate_cc = v_zile_neindexate
v_zile_indexate_cc = v_zile_indexate
v_suma_cm_neindexata_cc = v_suma_cm_neindexata
v_suma_cm_indexata_cc = v_suma_cm_indexata
v_d_91_cc = v_data_acordare_indexare
)

return
/* CM x indemnizatie */
v_suma_cm,
v_total_intreprindere, /* Conta CM Intrep */
/* v_total_CAS, Conta CM CAS */
v_compensatie_cm,
v_cm_total,

CM_SANATATE_ANGAJATOR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CM_SANATATE_ANGAJATOR */

default for CM_SANATATE_ANGAJATOR is 0 /* 0.75 */


default for BAZA_SANATATE_ANGAJAT_ASG_MONTH is 0
default for PROFIT_ASG_MONTH is 0
default for TOTAL_PRESTATII_INTR_ASG_MONTH is 0
default for FACILITATI_SUPUSE_IMPOZITARII_ASG_MONTH is 0

/* -------------------------------------------------------------------------
Baza CM Sanatate angajator
------------------------------------------------------------------------- */
/*
fond de salarii realizat =
drepturi salariale si / sau drepturi asimilate salariilor

drepturi asimilate salariilor =


a) Avantaje in bani si in natura [art. 56 (2) din Codul Fiscal ]

*/
v_baza_calcul =
BAZA_SANATATE_ANGAJAT_ASG_MONTH +
FACILITATI_SUPUSE_IMPOZITARII_ASG_MONTH +
TOTAL_PRESTATII_INTR_ASG_MONTH -
PROFIT_ASG_MONTH
/* -------------------------------------------------------------------------
End: Baza CM Sanatate angajator
------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------
CM Sanatate angajator
------------------------------------------------------------------------- */
v_contributie = round((CM_SANATATE_ANGAJATOR / 100) * v_baza_calcul)
/* -------------------------------------------------------------------------
End: CM Sanatate angajator
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Conta
------------------------------------------------------------------------- */
if v_contributie <> 0 then v_suma = v_contributie
/* -------------------------------------------------------------------------
End: Conta
------------------------------------------------------------------------- */

return
v_baza_calcul,
v_contributie,

/* Conta CM Sanatate angajator */


v_suma

/* End: Formula: CM_SANATATE_ANGAJATOR */

CM_SPITALIZARE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CM_SPITALIZARE */

default for DATA_INCEPUT_CM is '01-FEB-2000' (date)


default for DATA_SFARSIT_CM is '01-FEB-2000' (date)

default for ELEMENT_NAME is ' '


default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

inputs are
DATA_INCEPUT_CM,
DATA_SFARSIT_CM

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')
/* zi libera exceptie - zi libera in care se lucreaza*/
/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/* ----------------
luna
----------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT_CM)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, DATA_SFARSIT_CM )

v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
---------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------*/
v_zile = v_z

/* ----------------
End: luna
----------------- */

/* stop
----------------*/
if (DATA_SFARSIT_CM <= PAY_PROC_PERIOD_END_DATE) then v_stop = ELEMENT_NAME + ': Stop
'

return
v_zile

/* End: Formula: CM_SPITALIZARE */

CM_SUSPENDARE_CONTRACT
/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CM_SUSPENDARE_CONTRACT vs. 1 jan 06


Versiune fara functiile lui Radu Ionescu
*/

/* CM Suspendare contract
-----------------------------------------------------------------------------------------------------*/
default for DATA_INCEPUT is '01-FEB-2000' (DATE)
default for DATA_SFARSIT is '01-FEB-2000' (DATE)
default for COD_INDEMNIZATIE is ' '
/* End: CM Suspendare contract
-----------------------------------------------------------------------------------------------------*/
default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2000' (DATE)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2000' (DATE)
default for DURATA_NORMALA_TIMP_LUCRU is 8
default for DATA_PLATII_SALARIULUI is 'C'
default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0
default for SOMAJ_CM_SUSPENDAT_ASG_RUN is 0
default for PROCESARE_2_ASG_RUN is 0 /* Calcul luna */
default for PROCESARE_1_ASG_RUN is 0 /* Calcul avans */

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
COD_INDEMNIZATIE

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')
/* zi libera exceptie - zi libera in care se lucreaza*/
/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

v_procent_boala = 100
if (COD_INDEMNIZATIE = '10') then v_procent_boala = 25
if (COD_INDEMNIZATIE = '11') then v_procent_boala = 25
if (COD_INDEMNIZATIE = '16') then v_procent_boala = 25

/* ---------------------------------------------------------------------
Suspendare contract CM [luna]
---------------------------------------------------------------------*/
v_data_inceperii_in_luna = greatest(DATA_INCEPUT, PAY_PROC_PERIOD_START_DATE)
v_data_incheierii_in_luna = least(DATA_SFARSIT, PAY_PROC_PERIOD_END_DATE)
v_zile_calendaristice = 0
if v_data_inceperii_in_luna <= v_data_incheierii_in_luna then
v_zile_calendaristice = DAYS_BETWEEN(v_data_incheierii_in_luna, v_data_inceperii_in_luna) + 1

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceperii_in_luna /* data inceput */
v_d_s = v_data_incheierii_in_luna /* data sfarsit */
v_z = GET_WORKING_DAYS(v_d_i, v_d_s) /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_lucratoare = v_z
v_z_lucratoare = v_z

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_ore_lucratoare = v_zile_lucratoare * (v_procent_boala / 100) * v_durata_muncii

if (COD_INDEMNIZATIE = '10' or COD_INDEMNIZATIE = '16' or COD_INDEMNIZATIE = '11') then


v_zile_lucratoare = round(v_zile_lucratoare * (v_procent_boala / 100))

/* -------------------------------------------
Motiv
------------------------------------------- */
v_motiv_suspendare = '50_2' /* incapacitate temporara munca */
if (COD_INDEMNIZATIE = 'CC') then v_motiv_suspendare = '51_1' /* cresterea copilului */
if (COD_INDEMNIZATIE = '08') then v_motiv_suspendare = '50_1' /* maternitate */
if (COD_INDEMNIZATIE = '07') then v_motiv_suspendare = '50_3' /* Carantina */
if (COD_INDEMNIZATIE = '09') then v_motiv_suspendare = '51_2' /* Ingrijire copil bolnav */
/* -------------------------------------------
End: Motiv
------------------------------------------- */
/* -------------------------------------------
zile scutite de contributie somaj
-------------------------------------------- */
v_r = SOMAJ_CM_SUSPENDAT_ASG_RUN
v_data_inceput_som = DATA_INCEPUT /*MAX_DATA_CM_CON(1)*/
v_data_sfarsit_som = DATA_SFARSIT /*MAX_DATA_CM_CON(2)*/

v_m1 = ELEMENT_NAME + ' i='+TO_TEXT(v_data_inceput_som, 'DD-MON-RRRR')


+ ' s='+TO_TEXT(v_data_sfarsit_som, 'DD-MON-RRRR')

v_zile_scutite_somaj = 0
/*v_initial = greatest(v_data_inceput_som, PAY_PROC_PERIOD_START_DATE)*/
v_initial = v_data_inceput_som
v_final = least(v_data_sfarsit_som, PAY_PROC_PERIOD_END_DATE)
v_d_31 = ADD_DAYS(v_initial,30)
if
/* numai CM > 30 zile calendaristice*/
(COD_INDEMNIZATIE = '01' or COD_INDEMNIZATIE = '02' or COD_INDEMNIZATIE = '03' or
COD_INDEMNIZATIE = '04' or COD_INDEMNIZATIE = '05' or COD_INDEMNIZATIE = '06' or
COD_INDEMNIZATIE = '10' or COD_INDEMNIZATIE = '16' or
COD_INDEMNIZATIE = '11' or COD_INDEMNIZATIE = '12' or
COD_INDEMNIZATIE = '13' or COD_INDEMNIZATIE = '14' or COD_INDEMNIZATIE = '15') and
((v_initial <= v_d_31 and v_d_31 <= v_final) or (v_initial > v_d_31)) then
( /* N 1 */
v_d_in = greatest(v_initial, v_d_31, PAY_PROC_PERIOD_START_DATE) /* data inceput */
v_d_sf = v_final /* data sfarsit */
v_zile_scutite_somaj = GET_WORKING_DAYS(v_d_in, v_d_sf)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_d_in /* data inceput */
v_d_s = v_d_sf /* data sfarsit */
v_z = v_zile_scutite_somaj /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_scutite_somaj = v_z
if(v_r = v_z) then
v_zile_scutite_somaj = 0

if (COD_INDEMNIZATIE = '10' or COD_INDEMNIZATIE = '16' or


COD_INDEMNIZATIE = '11') then v_zile_scutite_somaj = 0
) /* N 1 */
/* indiferent de durata */
if (COD_INDEMNIZATIE = 'CC' or COD_INDEMNIZATIE = '07' or
COD_INDEMNIZATIE = '08' or COD_INDEMNIZATIE = '09' or
(COD_INDEMNIZATIE = '00' and GET_TABLE_VALUE('CM neprezentat', 'Somaj', '1')='Zile Scutite') ) then
v_zile_scutite_somaj = v_zile_lucratoare
/* --------------------------------------------------
End: zile scutite de contributie somaj
--------------------------------------------------- */
/* ----------------------------------------------------------------------
End: CM Suspendare contract
----------------------------------------------------------------------*/
/* ------------------------------------------------------------------
chenzina I
------------------------------------------------------------------ */
/* numai in Calcul avans */
if PROCESARE_1_ASG_RUN = 1 and
(v_plata = 'C') then
( /* N 1 */
/* (1-15 ale lunii) */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)
/* nr de zile lucratoare din chenzina I
------------------------------------------------- */
v_d_in = v_data_inceperii_in_luna /* data inceput */
v_d_sf = least(v_d_15, v_data_incheierii_in_luna) /* data sfarsit */
v_zile_lucratoare_chenzina_I = GET_WORKING_DAYS(v_d_in, v_d_sf)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_d_in /* data inceput */
v_d_s = v_d_sf /* data sfarsit */
v_z = v_zile_lucratoare_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_lucratoare_chenzina_I = v_z

if (COD_INDEMNIZATIE = '10' or COD_INDEMNIZATIE = '16' or COD_INDEMNIZATIE = '11') then


v_zile_lucratoare_chenzina_I = round(v_zile_lucratoare_chenzina_I * (v_procent_boala / 100))

/* END: nr de zile lucratoare din chenzina I


------------------------------------------------*/
if (v_zile_lucratoare_chenzina_I > 0) then
(
v_cod_indemn_chenzina_I = COD_INDEMNIZATIE
v_data_inceput_chenzina_I = DATA_INCEPUT
v_data_sfarsit_chenzina_I = DATA_SFARSIT
v_zile_chenzina_I = v_zile_lucratoare_chenzina_I
v_ore_chenzina_I = v_zile_chenzina_I * v_durata_muncii
)
) /* N 1 */
/* ------------------------------------------------------------------
End: chenzina I
------------------------------------------------------------------ */

/* CAS
------------------- */
if (PROCESARE_2_ASG_RUN = 1) then
/* procesare numai la Calcul luna */
( /* N 1 */

if NOT (/*COD_INDEMNIZATIE = '02' or COD_INDEMNIZATIE = '03' or COD_INDEMNIZATIE = '04' or


COD_INDEMNIZATIE = '11' or */
COD_INDEMNIZATIE = '00') then
(
v_nr_salarii = 1

v_z = v_z_lucratoare
if (COD_INDEMNIZATIE = '10' or COD_INDEMNIZATIE = '16' or COD_INDEMNIZATIE = '11') then
v_z = roundup((v_z_lucratoare * 2) / v_durata_muncii, 0)

/* venit ce intra in Baza CAS angajat */


eff_date = PAY_PROC_PERIOD_START_DATE
SMIN = to_number(GET_TABLE_VALUE('Sal min economie', 'Valoare', '1', eff_date))
v_cm_cas_baza = (v_nr_salarii * SMIN) / (ZILE_LUCRATOARE_LUNA_ASG_RUN) * v_z
)

) /* N 1 */
/* End : CAS
------------------- */

return
/* CM Suspendare contract */
v_zile_calendaristice,
v_zile_lucratoare, /* CM luna */
v_ore_lucratoare, /* CM luna */
v_motiv_suspendare,
v_zile_scutite_somaj,
/* CM luna */
DATA_INCEPUT,
DATA_SFARSIT,
COD_INDEMNIZATIE,
/* CM chenzina I */
v_cod_indemn_chenzina_I,
v_data_inceput_chenzina_I,
v_data_sfarsit_chenzina_I,
v_zile_chenzina_I,
v_ore_chenzina_I,
/* CM CAS */
v_cm_cas_baza,
v_m1

/* End: Formula: CM_SUSPENDARE_CONTRACT */

CM_TIMP

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CM_TIMP */

default for PROCESARE is 0

v_procesare = 1
return v_procesare

/* End: Formula: CM_TIMP */

CM_VENITURI

/* corectii

se fac prin inlocuire */

default for CM_VENITURI_CORECTII_VENITURI_1_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_2_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_3_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_4_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_5_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_6_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_7_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_8_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_9_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_10_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_11_ENTRY_VALUE is 0

default for CM_VENITURI_CORECTII_VENITURI_12_ENTRY_VALUE is 0

/* End: corectii */

/* eventuala corectie de venituri */

if (CM_VENITURI_CORECTII_VENITURI_1_ENTRY_VALUE was not defaulted)

then

v_venituri_1 = CM_VENITURI_CORECTII_VENITURI_1_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_2_ENTRY_VALUE was not defaulted)

then
v_venituri_2 = CM_VENITURI_CORECTII_VENITURI_2_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_3_ENTRY_VALUE was not defaulted)

then

v_venituri_3 = CM_VENITURI_CORECTII_VENITURI_3_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_4_ENTRY_VALUE was not defaulted)

then

v_venituri_4 = CM_VENITURI_CORECTII_VENITURI_4_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_5_ENTRY_VALUE was not defaulted)

then

v_venituri_5 = CM_VENITURI_CORECTII_VENITURI_5_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_6_ENTRY_VALUE was not defaulted)

then

v_venituri_6 = CM_VENITURI_CORECTII_VENITURI_6_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_7_ENTRY_VALUE was not defaulted)

then

v_venituri_7 = CM_VENITURI_CORECTII_VENITURI_7_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_8_ENTRY_VALUE was not defaulted)

then

v_venituri_8 = CM_VENITURI_CORECTII_VENITURI_8_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_9_ENTRY_VALUE was not defaulted)


then

v_venituri_9 = CM_VENITURI_CORECTII_VENITURI_9_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_10_ENTRY_VALUE was not defaulted)

then

v_venituri_10 = CM_VENITURI_CORECTII_VENITURI_10_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_11_ENTRY_VALUE was not defaulted)

then

v_venituri_11 = CM_VENITURI_CORECTII_VENITURI_11_ENTRY_VALUE

if (CM_VENITURI_CORECTII_VENITURI_12_ENTRY_VALUE was not defaulted)

then

v_venituri_12 = CM_VENITURI_CORECTII_VENITURI_12_ENTRY_VALUE

/* End: eventuala corectie de venituri */

return

/* se incarca numai lunile corectate */

v_venituri_1,

v_venituri_2,

v_venituri_3,

v_venituri_4,

v_venituri_5,

v_venituri_6,

v_venituri_7,
v_venituri_8,

v_venituri_9,

v_venituri_10,

v_venituri_11,

v_venituri_12

CM_VENITURI_LUNA

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CM_VENITURI_LUNA */

default for CM_VENITURI_LUNA_ASG_MONTH is 0

v_cm_vn = CM_VENITURI_LUNA_ASG_MONTH

return v_cm_vn

/* End: Formula: CM_VENITURI_LUNA */

CM_XX

/********************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/
/* Formula: CM_XX */

default for CM_Total is 0


default for Zile_Total is 0
default for LANSAT_DE is ' '

default for CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH is 0


default for CM_SALARIU_BAZA_LUNAR_ASG_MONTH is 0
/* contractul colectiv de munca nu prevede compensatia */
default for COMPENSATIE_INDEMNIZATIE_MATERNITATE is 'N'
default for ASG_NUMBER is ' '
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2003' (date)
default for ELEMENT_NAME is ' '
default for CM_1_ZILE_SPITALIZARE_ASG_RUN is 0
default for CM_SPORURI_NEGOCIATE_PROCENTE_ASG_MONTH is 0
default for VECHIME_MUNCA_ANI_ASG_RUN is 0

inputs are
CM_Total,
Zile_Total,
LANSAT_DE

/* -------------------------------------------------------------
CM Compensatie - pentru unele tipuri de boala
---------------------------------------------------------------- */
v_sit = ' '
v_cm_comp = 'N'
eff_date = PAY_PROC_PERIOD_END_DATE

v_sit = substr(ELEMENT_NAME, 4, 2)

/* contractul colectiv prevede acordarea compensatiei */


if (GET_TABLE_VALUE('CM Compensatie', 'Situatie', v_sit, eff_date) = 'D') and v_cm_comp = 'N' then
(
/* Compensatie = ( Salariu de baz brut lunar / Nr. de zile lucrtoare din lun *
zile de concediu de maternitate compensate din luna ) - Indemnizaia de materniate */

v_sal = CM_SALARIU_BAZA_LUNAR_ASG_MONTH *
( 1 + CM_SPORURI_NEGOCIATE_PROCENTE_ASG_MONTH / 100 )

x = round((v_sal / CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * Zile_Total) - CM_Total, 0)

if ( x > 0 )
/* se acorda compensatie */
then (v_cm_compensatie = x
v_fel = GET_LOOKUP_MEANING('RO_HR_CM_COMPENSATIE', '10')
v_cm_comp = 'D')

/* nu se acorda compensatie >> se emite un mesaj de notificare */


else v_m1 = ELEMENT_NAME + ': CM Compensatie = ' + to_text(x) + ' NU se acorda '
)
/* -------------------------------------------------------------
End:CM Compensatie - pentru unele tipuri de boala
---------------------------------------------------------------- */
/* -------------------------------------------------------------
CM Compensatie - pentru spitalizare
---------------------------------------------------------------- */
v_sit = ' '
if substr(LANSAT_DE, 4, 1) = '1' and CM_1_ZILE_SPITALIZARE_ASG_RUN > 0 then v_sit = 'SP'

/* contractul colectiv prevede acordarea compensatiei */


if v_sit <> ' ' and GET_TABLE_VALUE('CM Compensatie', 'Situatie', v_sit, eff_date) = 'D' and
v_cm_comp = 'N' then
(
/* Compensatie = ( Salariu de baz brut lunar / Nr. de zile lucrtoare din lun *
zile de concediu de maternitate compensate din luna ) - Indemnizaia de materniate */

v_ani = VECHIME_MUNCA_ANI_ASG_RUN
v_pr = 75
if v_ani > 20 then v_pr = 100

v_sal = CM_SALARIU_BAZA_LUNAR_ASG_MONTH *
( 1 + CM_SPORURI_NEGOCIATE_PROCENTE_ASG_MONTH / 100 )

x = (v_sal / CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * Zile_Total) - CM_Total


x = round(x * v_pr / 100, 0)

if ( x > 0 )
/* se acorda compensatie */
then (v_cm_compensatie = x
v_fel = GET_LOOKUP_MEANING('RO_HR_CM_COMPENSATIE', '10')
v_cm_comp = 'D')

/* nu se acorda compensatie >> se emite un mesaj de notificare */


else v_m1 = ELEMENT_NAME + ': CM Compensatie = ' + to_text(x) + ' NU se acorda '
)

/* -------------------------------------------------------------
End: CM Compensatie - pentru spitalizare
---------------------------------------------------------------- */

/* -------------------------------------------------------------
CM Compensatie - indemnizatie maternitate
---------------------------------------------------------------- */
/*
art. 66 din Contractul de Munc nr. 1116/2003:
In cazul n care salariata se afl n concediu de maternitate,
unitatea va compensa, diferena dintre salariul de baz i indemnizaia legal
concediu de maternitate >> cod indemnizatie boala = 08 Sarcina si lehuzie
*/

if
/* contractul colectiv prevede acordarea compensatiei */
(COMPENSATIE_INDEMNIZATIE_MATERNITATE = 'Y') then
(
/* Compensatie = ( Salariu de baz brut lunar / Nr. de zile lucrtoare din lun *
zile de concediu de maternitate compensate din luna ) - Indemnizaia de materniate */

x = round((CM_SALARIU_BAZA_LUNAR_ASG_MONTH /
CM_ZILE_LUCRATOARE_LUNA_ASG_MONTH * Zile_Total) - CM_Total, -3)

if ( x > 0 )
/* se acorda compensatie */
then (v_cm_compensatie = x
v_fel = GET_LOOKUP_MEANING('RO_HR_CM_COMPENSATIE', '10'))

/* nu se acorda compensatie >> se emite un mesaj de notificare */


else v_m1 = 'Notificare: ' + ELEMENT_NAME + ' CM Compensatie = ' + to_text(x) + ' NU se acorda '
)

/* -------------------------------------------------------------
End: CM Compensatie - indemnizatie maternitate
---------------------------------------------------------------- */

return
v_cm_compensatie,
v_fel,
v_m1

/* End: Formula: CM_XX */

CM_ZILE_CONTRIBUTIVE

/* corectii */

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_1_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_2_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_3_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_4_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_5_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_6_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_7_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_8_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_9_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_10_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_11_ENTRY_VALUE is 0

default for CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_12_ENTRY_VALUE is 0

/* eventuala corectie a zilelor lucratoare */


if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_1_ENTRY_VALUE was not defaulted)

then

v_zile_1 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_1_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_2_ENTRY_VALUE was not defaulted)

then

v_zile_2 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_2_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_3_ENTRY_VALUE was not defaulted)

then

v_zile_3 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_3_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_4_ENTRY_VALUE was not defaulted)

then

v_zile_4 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_4_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_5_ENTRY_VALUE was not defaulted)

then

v_zile_5 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_5_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_6_ENTRY_VALUE was not defaulted)

then

v_zile_6 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_6_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_7_ENTRY_VALUE was not defaulted)

then

v_zile_7 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_7_ENTRY_VALUE
if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_8_ENTRY_VALUE was not defaulted)

then

v_zile_8 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_8_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_9_ENTRY_VALUE was not defaulted)

then

v_zile_9 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_9_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_10_ENTRY_VALUE was not defaulted)

then

v_zile_10 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_10_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_11_ENTRY_VALUE was not defaulted)

then

v_zile_11 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_11_ENTRY_VALUE

if (CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_12_ENTRY_VALUE was not defaulted)

then

v_zile_12 = CM_ZILE_CONTRIBUTIVE_CORECTII_ZILE_12_ENTRY_VALUE

/* End: eventuala corectie a zilelor lucratoare */

return

v_zile_1,

v_zile_2,

v_zile_3,
v_zile_4,

v_zile_5,

v_zile_6,

v_zile_7,

v_zile_8,

v_zile_9,

v_zile_10,

v_zile_11,

v_zile_12

CM_ZILE_CONTRIBUTIVE_LUNA

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CM_ZILE_CONTRIBUTIVE_LUNA */

default for CM_ZILE_CONTRIBUTIVE_LUNA_ASG_RUN is 0

v_cm_zile = CM_ZILE_CONTRIBUTIVE_LUNA_ASG_RUN

return v_cm_zile

/* End: Formula: CM_ZILE_CONTRIBUTIVE_LUNA */


CONCEDII

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CONCEDII */

default for CONCEDII_ASG_MONTH is 0

v_concedii = CONCEDII_ASG_MONTH

if (v_concedii <> 0) then v_suma = v_concedii

return

v_concedii,

/* Conta concedii */

v_suma

/* End: Formula: CONCEDII */

CONCEDIU_CU_PLATA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CONCEDIU_CU_PLATA */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
default for FEL is ' ' /* cod = xxZZZ */
/*
10005-Concediu Formare Profesionala; Enable

10010-Concediu Formare Profesionala


20999-Concediu pentru alaptare >> 2 ore pe zi
30005-Concediu mutare
*/

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)
default for CCP_10_ASG_YTD is 0
default for CCP_20_ASG_YTD is 0
default for CCP_30_ASG_YTD is 0
default for CCP_40_ASG_YTD is 0
default for CCP_50_ASG_YTD is 0
/* calcul luna */
default for PROCESARE_2_ASG_RUN is 0

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0
default for PROCESARE_1_ASG_RUN is 0 /* Calcul avans */

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
FEL

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* nr de ore pe zi
----------------- */

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU) then


v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

v_ore_pe_zi = v_durata_muncii
if (substr(FEL,1,2) = '20') then v_ore_pe_zi = 2

/* ---------------------------------------------------------------------------------------
zile drept + consumate
--------------------------------------------------------------------------------------- */
v_zile_drept = to_number(rtrim(substr(FEL,3,3)))

/* zile consumate ianintea procesarii curente */


v_zile_consumate = 0
if (substr(FEL,1,2) = '10') then v_zile_consumate = CCP_10_ASG_YTD
if (substr(FEL,1,2) = '20') then v_zile_consumate = CCP_20_ASG_YTD
if (substr(FEL,1,2) = '30') then v_zile_consumate = CCP_30_ASG_YTD
if (substr(FEL,1,2) = '40') then v_zile_consumate = CCP_40_ASG_YTD
if (substr(FEL,1,2) = '50') then v_zile_consumate = CCP_50_ASG_YTD
/* ---------------------------------------------------------------------------------------
End: zile drept + consumate
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
luna
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, DATA_SFARSIT )

v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile = v_z

if (v_zile + v_zile_consumate > v_zile_drept) then


(
v_m1 = 'Eroare ' + ELEMENT_NAME +
': Zile solicitate=' + to_text(v_zile + v_zile_consumate) + ' > ' + ' Zile drept=' + to_text(v_zile_drept)
return v_m1
)

v_ore = v_zile * v_ore_pe_zi


/* ---------------------------------------------------------------------------------------
End: luna
--------------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
chenzina I
--------------------------------------------------------------------------------------- */
/* numai in Calcul avans */
if PROCESARE_1_ASG_RUN = 1 and
(v_plata = 'C') then
( /* N 1 */
/* (1-15 ale lunii) */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)

v_di_chenzina_I = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)


v_ds_chenzina_I = least(v_d_15, DATA_SFARSIT)
v_zile_chenzina_I = GET_WORKING_DAYS(v_di_chenzina_I, v_ds_chenzina_I)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_chenzina_I = v_z

v_ore_chenzina_I = v_zile_chenzina_I * v_ore_pe_zi


v_fel_chenzina_I = FEL
) /* N 1 */
/* ---------------------------------------------------------------------------------------
End: chenzina I
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
CCP Indemnizatie
--------------------------------------------------------------------------------------- */
/* calcul luna */
if (PROCESARE_2_ASG_RUN = 1) then
(
v_ccp_indemn_zile = v_zile
v_ccp_indemn_ore = v_ore
v_fel = FEL
)
/* ---------------------------------------------------------------------------------------
End: CCP Indemnizatie
--------------------------------------------------------------------------------------- */

/* stop
-----------------------------------------------------------------------------------*/
if (DATA_SFARSIT <= PAY_PROC_PERIOD_END_DATE) then
v_stop = ELEMENT_NAME + ': Stop '

if (substr(FEL,1,2) = '10') then


(v_zile_10 = v_zile
v_fel_10 = FEL
v_d_i_10 = DATA_INCEPUT
v_d_s_10 = DATA_SFARSIT
v_ore_10 = v_ore)
if (substr(FEL,1,2) = '20') then
(v_zile_20 = v_zile
v_fel_20 = FEL
v_d_i_20 = DATA_INCEPUT
v_d_s_20 = DATA_SFARSIT
v_ore_20 = v_ore)
if (substr(FEL,1,2) = '30') then
(v_zile_30 = v_zile
v_fel_30 = FEL
v_d_i_30 = DATA_INCEPUT
v_d_s_30 = DATA_SFARSIT
v_ore_30 = v_ore)
if (substr(FEL,1,2) = '40') then
(v_zile_40 = v_zile
v_fel_40 = FEL
v_d_i_40 = DATA_INCEPUT
v_d_s_40 = DATA_SFARSIT
v_ore_40 = v_ore)
if (substr(FEL,1,2) = '50') then
(v_zile_50 = v_zile
v_fel_50 = FEL
v_d_i_50 = DATA_INCEPUT
v_d_s_50 = DATA_SFARSIT
v_ore_50 = v_ore)

return
v_stop,

/* comune */
DATA_INCEPUT,
DATA_SFARSIT,
FEL,

/* CCP [nr] */
v_zile_10,
v_ore_10,
v_fel_10,
v_d_i_10,
v_d_s_10,
v_zile_20,
v_ore_20,
v_fel_20,
v_d_i_20,
v_d_s_20,
v_zile_30,
v_ore_30,
v_fel_30,
v_d_i_30,
v_d_s_30,
v_zile_40,
v_ore_40,
v_fel_40,
v_d_i_40,
v_d_s_40,
v_zile_50,
v_ore_50,
v_fel_50,
v_d_i_50,
v_d_s_50,

/* CCP Luna */
v_zile,
v_ore,

/* CCP chenzina I */
v_fel_chenzina_I,
v_zile_chenzina_I ,
v_ore_chenzina_I,
v_di_chenzina_I,
v_ds_chenzina_I,

/* CCP Indemnizatie */
v_ccp_indemn_zile,
v_ccp_indemn_ore,
v_fel

/* End: Formula: CONCEDIU_CU_PLATA */

CONCEDIU_FARA_PLATA_1

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CONCEDIU_FARA_PLATA */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
default for FEL is ' ' /* cod = xxZZZ */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)
default for CFP_10_ASG_YTD is 0
default for CFP_20_ASG_YTD is 0
default for CFP_30_ASG_YTD is 0
default for CFP_40_ASG_YTD is 0
default for CFP_50_ASG_YTD is 0
default for PROCESARE_2_ASG_RUN is 0 /* Calcul luna */

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
FEL
/* CSL: Plata C=Chenzinl sau L=Lunar */
v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')
/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
zile drept + consumate
--------------------------------------------------------------------------------------- */
v_zile_drept = to_number(rtrim(substr(FEL,3,3)))

/* zile consumate ianintea procesarii curente */


v_zile_consumate = 0
if (substr(FEL,1,2) = '10') then v_zile_consumate = CFP_10_ASG_YTD
if (substr(FEL,1,2) = '20') then v_zile_consumate = CFP_20_ASG_YTD
if (substr(FEL,1,2) = '30') then v_zile_consumate = CFP_30_ASG_YTD
if (substr(FEL,1,2) = '40') then v_zile_consumate = CFP_40_ASG_YTD
if (substr(FEL,1,2) = '50') then v_zile_consumate = CFP_50_ASG_YTD
/* ---------------------------------------------------------------------------------------
End: zile drept + consumate
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
luna
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, DATA_SFARSIT )
v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile = v_z

if (v_zile + v_zile_consumate > v_zile_drept) then


(
v_m1 = 'Eroare ' + ELEMENT_NAME +
' Zile CFP ' + to_text(v_zile + v_zile_consumate) +
' > ' + ' Zile drept ' + to_text(v_zile_drept)
)

v_ore = v_zile * v_durata_muncii


/* ---------------------------------------------------------------------------------------
End: luna
--------------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
chenzina I
--------------------------------------------------------------------------------------- */
If (V_PLATA = 'C') then
( /* N 1 */
/* (1-15 ale lunii) */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)

v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)


v_data_sfarsit = least(v_d_15, DATA_SFARSIT)
v_zile_chenzina_I = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_chenzina_I = v_z

v_ore_chenzina_I = v_zile_chenzina_I * v_durata_muncii


) /* N 1 */
/* ---------------------------------------------------------------------------------------
End: chenzina I
--------------------------------------------------------------------------------------- */

/* stop
-----------------------------------------------------------------------------------*/
if (DATA_SFARSIT <= PAY_PROC_PERIOD_END_DATE) then
v_stop = 'Stop ' + ELEMENT_NAME

if (PROCESARE_2_ASG_RUN = 1)
then
/* procesare numai la Calcul luna */
(
if (substr(FEL,1,2) = '10') then
(v_zile_10 = v_zile
v_fel_10 = FEL
v_d_i_10 = DATA_INCEPUT
v_d_s_10 = DATA_SFARSIT
v_ore_10 = v_ore)
if (substr(FEL,1,2) = '20') then
(v_zile_20 = v_zile
v_fel_20 = FEL
v_d_i_20 = DATA_INCEPUT
v_d_s_20 = DATA_SFARSIT
v_ore_20 = v_ore)
if (substr(FEL,1,2) = '30') then
(v_zile_30 = v_zile
v_fel_30 = FEL
v_d_i_30 = DATA_INCEPUT
v_d_s_30 = DATA_SFARSIT
v_ore_30 = v_ore)
if (substr(FEL,1,2) = '40') then
(v_zile_40 = v_zile
v_fel_40 = FEL
v_d_i_40 = DATA_INCEPUT
v_d_s_40 = DATA_SFARSIT
v_ore_40 = v_ore)
if (substr(FEL,1,2) = '50') then
(v_zile_50 = v_zile
v_fel_50 = FEL
v_d_i_50 = DATA_INCEPUT
v_d_s_50 = DATA_SFARSIT
v_ore_50 = v_ore)
)
/* End: procesare numai la Calcul luna */

return
v_stop,

/* comune */
DATA_INCEPUT,
DATA_SFARSIT,
FEL,
v_m1,

/* CFP [nr] */
v_zile_10,
v_ore_10,
v_fel_10,
v_d_i_10,
v_d_s_10,
v_zile_20,
v_ore_20,
v_fel_20,
v_d_i_20,
v_d_s_20,
v_zile_30,
v_ore_30,
v_fel_30,
v_d_i_30,
v_d_s_30,
v_zile_40,
v_ore_40,
v_fel_40,
v_d_i_40,
v_d_s_40,
v_zile_50,
v_ore_50,
v_fel_50,
v_d_i_50,
v_d_s_50,

/* CFP Luna */
v_zile,
v_ore,

/* CFP chenzina I */
v_zile_chenzina_I ,
v_ore_chenzina_I

/* End: Formula: CONCEDIU_FARA_PLATA */


CONCEDIU_ODIHNA

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CONCEDIU_ODIHNA */

default for INCEPUT_CONCEDIU is '01-JAN-1900' (date)


default for SFARSIT_CONCEDIU is '31-DEC-4712' (date)
default for ACORDAT_IN_AVANS is 'N'
default for AVANS is 0
default for PROCENT is 0
default for DATA_PLATA is '01-JAN-1900' (date)
default for INDEMNIZATIE_ZI is 0

default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)


default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2003' (date)
default for ASG_HOURS is 8
default for ELEMENT_NAME is ' '
default for ABSENTE_CO_ASG_YTD is 0
default for ZILE_CO_AN_CURENT_ASG_RUN is 0
default for PROCESARE_1_ASG_RUN is 0 /* Calcul avans */
default for PROCESARE_2_ASG_RUN is 0 /* Calcul luna */
default for PROCESARE_4_ASG_RUN is 0 /* Calcul salarii */

inputs are
INCEPUT_CONCEDIU,
SFARSIT_CONCEDIU,
ACORDAT_IN_AVANS,
AVANS,
PROCENT,
DATA_PLATA,
INDEMNIZATIE_ZI

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')

v_inceput_concediu = INCEPUT_CONCEDIU
v_sfarsit_concediu = SFARSIT_CONCEDIU

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/* ------------------------------------
Zile CO din luna curenta
--------------------------------------- */
v_data_inceput_luna_curenta = greatest(INCEPUT_CONCEDIU, PAY_PROC_PERIOD_START_DATE)
v_data_sfarsit_luna_curenta = least(SFARSIT_CONCEDIU, PAY_PROC_PERIOD_END_DATE)

z_lucratoare_luna = GET_WORKING_DAYS(v_data_inceput_luna_curenta, v_data_sfarsit_luna_curenta)

/* corectie nr de zile
-------------------------- */
v_d_i = v_data_inceput_luna_curenta /* data inceput */
v_d_s = v_data_sfarsit_luna_curenta /* data sfarsit */

v_z = z_lucratoare_luna /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1

z_lucratoare_luna = v_z

o_lucratoare_luna = z_lucratoare_luna * ASG_HOURS

v_z_lucratoare_lu = z_lucratoare_luna
v_o_lucratoare_lu = o_lucratoare_luna
/* ------------------------------------
End: Zile CO din luna curenta
--------------------------------------- */

/* ------------------------------------
Zile CO din chenzina I
--------------------------------------- */

/* numai in Calcul avans */


if PROCESARE_1_ASG_RUN = 1 and
(v_plata = 'C') then
( /* N 1 */
/* (1-15 ale lunii) */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)
v_di_chenzina_I = greatest( PAY_PROC_PERIOD_START_DATE, INCEPUT_CONCEDIU)
v_ds_chenzina_I = least(v_d_15, SFARSIT_CONCEDIU)
v_zile_chenzina_I = GET_WORKING_DAYS(v_di_chenzina_I, v_ds_chenzina_I)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_di_chenzina_I /* data inceput */
v_d_s = v_ds_chenzina_I /* data sfarsit */
v_z = v_zile_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_chenzina_I = v_z

v_ore_chenzina_I = v_zile_chenzina_I * ASG_HOURS


v_fel_chenzina_I = ELEMENT_NAME
) /* N 1 */

/* ------------------------------------
End: Zile CO din chenzina I
--------------------------------------- */

/* ------------------------------------
Zile CO totale > daca este prima luna
--------------------------------------- */
v_zile_lucratoare_total = 0
if (INCEPUT_CONCEDIU >= PAY_PROC_PERIOD_START_DATE) and
(INCEPUT_CONCEDIU <= PAY_PROC_PERIOD_END_DATE) then
(
v_zile_lucratoare_total = GET_WORKING_DAYS(INCEPUT_CONCEDIU, SFARSIT_CONCEDIU)

/* corectie nr de zile
------------------------- */
v_d_i = INCEPUT_CONCEDIU /* data inceput */
v_d_s = SFARSIT_CONCEDIU /* data sfarsit */

v_z = v_zile_lucratoare_total /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1

v_zile_lucratoare_total = v_z
)
/* ------------------------------------
End: Zile CO totale
--------------------------------------- */

/* ------------------------------------
Zile CO ramase
--------------------------------------- */
v_data_inceput_z_ramase = greatest(INCEPUT_CONCEDIU, PAY_PROC_PERIOD_START_DATE)
v_data_sfarsit_z_ramase = SFARSIT_CONCEDIU

z_ramase = GET_WORKING_DAYS(v_data_inceput_z_ramase, v_data_sfarsit_z_ramase)

/* corectie nr de zile
-------------------------- */
v_d_i = v_data_inceput_z_ramase /* data inceput */
v_d_s = v_data_sfarsit_z_ramase /* data sfarsit */

v_z = z_ramase /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1

z_ramase = v_z
/* ------------------------------------
End: Zile CO ramase
--------------------------------------- */

/* numai in Calcul luna */


if PROCESARE_2_ASG_RUN = 1 and
v_zile_lucratoare_total > (ZILE_CO_AN_CURENT_ASG_RUN - ABSENTE_CO_ASG_YTD) then
(
v_depasire = v_zile_lucratoare_total - (ZILE_CO_AN_CURENT_ASG_RUN - ABSENTE_CO_ASG_YTD)
v_m1 = ELEMENT_NAME + ': CO solicitat=' + to_text(v_zile_lucratoare_total) + ' zile.'
v_mesaj_eroare = 'Eroare ' + ELEMENT_NAME
+ ': S-a depasit dreptul de concediu cu ' + to_char(v_depasire) + ' zile.'
+ '(CO drept=' + to_char(ZILE_CO_AN_CURENT_ASG_RUN) + ' zile.'
+ ' CO consumat anterior =' + to_char(ABSENTE_CO_ASG_YTD) + ' zile.)'

return v_mesaj_eroare, v_m1


)

o_lucratoare_luna = z_lucratoare_luna * ASG_HOURS

if v_sfarsit_concediu = v_data_sfarsit_luna_curenta then v_stop = ELEMENT_NAME + 'Stop'

if ACORDAT_IN_AVANS = 'D' and PROCESARE_4_ASG_RUN = 1 then


(
v_zile_lucratoare_luna_avans = z_lucratoare_luna
v_zile_lucratoare_total_avans = v_zile_lucratoare_total /* numai in prima luna de CO este dif. de 0 */
v_zile_ramase = z_ramase
v_lansare_avans = ELEMENT_NAME
if DATA_PLATA was not defaulted then v_d_plata = DATA_PLATA
)

if PROCESARE_2_ASG_RUN = 1 then
(
v_zile_lucratoare_luna = z_lucratoare_luna
v_ore_lucratoare_luna = o_lucratoare_luna
if
/* numai in prima luna de CO */
v_zile_lucratoare_total > 0 and
/* numai daca se plateste Avans CO */
ACORDAT_IN_AVANS = 'D' then
(
v_id_zile_total = v_zile_lucratoare_total
if AVANS was not defaulted then v_av = AVANS
if PROCENT was not defaulted then v_pr = PROCENT
)

v_lansare = ELEMENT_NAME /* Indemnizatie concediu odihna 1 */


if INDEMNIZATIE_ZI was not defaulted then v_id_zi = INDEMNIZATIE_ZI
)

return
/* Indemnizatie concediu odihna 1 */
v_zile_lucratoare_luna,
v_ore_lucratoare_luna,
v_lansare,
v_id_zile_total, /* IV = Zile_total */
v_id_zi,
v_av,
v_pr,
/* Concediu odihna 1 */
v_stop,
/* Avans CO 1 */
v_zile_lucratoare_total_avans,
v_zile_lucratoare_luna_avans,
v_zile_ramase,
v_lansare_avans,
v_d_plata,
/* CO luna */
v_z_lucratoare_lu,
v_o_lucratoare_lu,
v_data_inceput_luna_curenta,
v_data_sfarsit_luna_curenta,

v_m1,

/* CO chenzina I */
v_fel_chenzina_I,
v_zile_chenzina_I,
v_ore_chenzina_I,
v_di_chenzina_I,
v_ds_chenzina_I

/* End: Formula: CONCEDIU_ODIHNA */

CONDITII_DE_MUNCA

/********************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CONDITII_DE_MUNCA */

default for JOB_KF_CONDITII_NORMALE is '0'


default for JOB_KF_CONDITII_DEOSEBITE is '0'

/* ---------------------------
Cond munca
------------------------------ */
v_cd = to_num(JOB_KF_CONDITII_DEOSEBITE )

v_fel = 2

/* lucreaza in acelasi timp in CD si CN */


if to_num(JOB_KF_CONDITII_NORMALE) > to_num(JOB_KF_CONDITII_DEOSEBITE ) then v_fel = 3
if to_num(JOB_KF_CONDITII_NORMALE) <> 0 then v_cn = to_num(JOB_KF_CONDITII_NORMALE)
v_cond_m = v_fel
/* ---------------------------
Cond munca
------------------------------ */

return
/* Conditii de munca */
v_fel,
v_cd,
v_cn,
v_cond_m
/* End: Formula: CONDITII_DE_MUNCA */

CONTA

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CONTA */

/*default for DATA_LICHIDARE is '01-FEB-1900' (date)*/


default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/*v_data = DATA_LICHIDARE*/
v_data = PAY_PROC_PERIOD_END_DATE

return v_data

/* End: Formula: CONTA */

CORECTII

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CORECTII */

default for CORECTII_ASG_MONTH is 0

v_corectii = CORECTII_ASG_MONTH
if (v_corectii <> 0) then v_suma = v_corectii

return v_corectii,

/* Conta corectii */

v_suma

/* End: Formula: CORECTII */

CORECTII

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: CORECTII */

default for CORECTII_ASG_MONTH is 0

v_corectii = CORECTII_ASG_MONTH

if (v_corectii <> 0) then v_suma = v_corectii

return v_corectii,
/* Conta corectii */

v_suma

/* End: Formula: CORECTII */

COTA_CARBUNE_RETINERE

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: COTA_CARBUNE_RETINERE */

default for REST_PLATA_2_ASG_MONTH is 0


default for ELEMENT_NAME is ' '
default for RATA is 0
default for COTA_CARBUNE_RETINERE_NEACOPERIT_ASG_ITD is 0

inputs are RATA

v_disponibil = REST_PLATA_2_ASG_MONTH
v_rata = RATA
v_neacoperit_initial = COTA_CARBUNE_RETINERE_NEACOPERIT_ASG_ITD

v_rata_de_platit = (v_rata + v_neacoperit_initial)

v_rata_retinuta = least(v_disponibil,v_rata_de_platit)

v_neacoperit_final = v_rata_de_platit - v_rata_retinuta


if (v_neacoperit_final > 0) then
v_mesaj_1 = ELEMENT_NAME + ' : Retinere neacoperita = ' + to_text(v_neacoperit_final)

return
v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta

/* End: Formula: COTA_CARBUNE_RETINERE */

COTIZATIE_SINDICAT

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: COTIZATIE_SINDICAT */

/* Cotizatie sindicat
< 1 procent
>= 1 suma */
default for COTIZATIE_SINDICAT is 0
default for BAZA_CALCUL is 'S' /* Default Salariu baza */

default for SALARIU_BAZA_NEGOCIAT_ASG_RUN is 0


default for TOTAL_BRUT_ASG_MONTH is 0
default for ELEMENT_NAME is ' '

default for PROCESARE_4_ASG_RUN is 0 /* Calcul salarii*/


default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2000' (DATE)

inputs are
COTIZATIE_SINDICAT,
BAZA_CALCUL

/* ----------------------------------------------------------------------------------
Cotizatie
----------------------------------------------------------------------------------- */
if (COTIZATIE_SINDICAT was not defaulted) then
(
/* procent */
if (COTIZATIE_SINDICAT < 1) then
(v_procent = COTIZATIE_SINDICAT
v_mesaj1 = ELEMENT_NAME + ': Procent = ' + to_text(COTIZATIE_SINDICAT)
v_suma = SALARIU_BAZA_NEGOCIAT_ASG_RUN
if BAZA_CALCUL = 'V' then v_suma = TOTAL_BRUT_ASG_MONTH
v_cotizatie_sindicat = round(v_procent * v_suma, 0))

/* suma */
if (COTIZATIE_SINDICAT > 1) then
(v_mesaj1 = ELEMENT_NAME + ': Suma = ' + to_text(COTIZATIE_SINDICAT)
v_cotizatie_sindicat = COTIZATIE_SINDICAT)
v_sindicat_retinut = v_cotizatie_sindicat
)
/* ----------------------------------------------------------------------------------
End: Cotizatie
----------------------------------------------------------------------------------- */

/* ----------------------------------------------------------------------------------
Cotizatie sindicat retinere
----------------------------------------------------------------------------------- */
if
/* Calcul salarii*/
(PROCESARE_4_ASG_RUN = 1) and
/* exista suma */
(v_cotizatie_sindicat <> 0) then v_retinere = v_cotizatie_sindicat
/* ----------------------------------------------------------------------------------
End: Cotizatie sindicat retinere
----------------------------------------------------------------------------------- */

return
v_suma,
v_cotizatie_sindicat,
v_sindicat_retinut, /* PV */

v_mesaj1,

/* Cotizatie sindicat retinere */


v_retinere

/* End: Formula: COTIZATIE_SINDICAT */

COTIZATIE_SINDICAT_RETINERE

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: COTIZATIE_SINDICAT_RETINERE */
/*
Configurarea permite:
sa se retina numai suma pentru care exista disponibil;
suma neacoperita este numai evidentiata in mesaje.

Corelatia dintre cotizatia retinuta si cea scazuta din venitul lunar impozabil se realizaeaza
manual prin modificarea E-Cotizatie sindicat, IV-Cotizatie sindicat la valoarea cotizatiei ce poate fi retinuta.
*/

/* Cotizatie sindicat retinere */


default for RATA is 0

default for REST_PLATA_1_ASG_MONTH is 0


default for ELEMENT_NAME is ' '

inputs are
RATA

v_disponibil = greatest(REST_PLATA_1_ASG_MONTH, 0)

v_rata_de_platit = RATA

v_sindicat_retinut = least(v_disponibil,v_rata_de_platit)

v_neacoperit = v_rata_de_platit - v_sindicat_retinut


if (v_neacoperit > 0) then v_mesaj1 = ELEMENT_NAME + ': Retinere neacoperita = ' + to_text(v_neacoperit)

if (v_sindicat_retinut <> 0) then v_suma = v_sindicat_retinut


return
v_neacoperit,
v_sindicat_retinut, /* PV */
v_mesaj1,

/* Conta Cotizatie sindicat */


v_suma

/* End: Formula: COTIZATIE_SINDICAT_RETINERE */

CO_DIFERENTE

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: CO_DIFERENTE

Formula calculeaza:
Nr de zile pentru:
1. Indemnizatia pentru concediul de odihn neefectuat
2. Indemnizatia de concediu de odihn de restituit

Lista modificarilor:
Data versiuni: Autori: Observatii:
+-----------------+----------------------+----------------------------
04-MAY-2005 Iancu Traian Versiuna initiala
+--------------------------------------------------------------------+

*/

default for ABSENTE_CO_ASG_YTD is 0


default for ZILE_CO_AN_CURENT_ASG_RUN is 0
default for ELEMENT_NAME is ' '

v_z_co_drept = ZILE_CO_AN_CURENT_ASG_RUN
v_z_co_consumate = ABSENTE_CO_ASG_YTD

/* CO diferente */
v_z_co_diferente = v_z_co_drept - v_z_co_consumate

if v_z_co_diferente = 0 then
v_m1 = ELEMENT_NAME + ': La plecare, angajatul nu are CO indemnizatie de restituit sau neefecutata'

/* Zile concediu de odihna neefectuate la data plecarii din unitate */


if v_z_co_diferente > 0 then
(
/* Indemnizatia pentru concediul de odihn neefectuat */
v_lans_co_neefectuat = ELEMENT_NAME
v_z_co_neefectuat = v_z_co_diferente
)
/* angajatul a efectuat mai multe zile de concediu de odihna decat cele cuvenite pentru perioada lucrata */
if v_z_co_diferente < 0 then
(
/* Indemnizatia de concediu de odihn de restituit */
v_lans_co_restituit = ELEMENT_NAME
v_z_co_restituit = v_z_co_diferente * (-1)
)

return
/* CO neefectuat */
v_lans_co_neefectuat,
v_z_co_neefectuat,

/* CO restituit */
v_lans_co_restituit,
v_z_co_restituit,

v_m1

/* End: Formula: CO_DIFERENTE */

DEDUCERE_PERSONALA_1

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: DEDUCERE_PERSONALA_1 (versiunea 1) */

default for DEDUCERE_BAZA is 0


default for DEDUCERE_DEPENDENT is 0
default for COEFICIENT_DEDUCERE_PERSOANA_INTRETINERE is 0.5
default for NR_MAX_PERS_INTRETINERE is 4

default for TOTAL_BRUT_ASG_MONTH is 0

default for VENIT_BRUT_1 is 1000


default for VENIT_BRUT_2 is 2000
default for VENIT_BRUT_3 is 3000

default for SALARIU_BAZA_NEGOCIAT_ASG_RUN is 0

default for COTIZATIE_SINDICAT_COUNT is 0

default for ASG_PAYROLL is ' '


default for ANGAJAT_IN_CURSUL_LUNII_ASG_RUN is 0
default for DEDUCERE_CORECTIE_ASG_RUN is 0
default for ELEMENT_NAME is ' '
default for MOD_ANGAJARE_FCT_BAZA_ALT_AGENT_ENTRY_VALUE is ' '
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
/* D = deducerea se calculeza la secundary assignment */
default for MOD_ANGAJARE_DEDUCERE_ASSIGNMENT_S_ENTRY_VALUE is ' '

default for TOTAL_BRUT_PER_MONTH is 0


default for ASG_PRIMARY is ' ' /* Yes / No */
default for COTIZATIE_SINDICAT_ASG_RUN is 0
default for CM_IMPOZIT_SCUTIRE_ASG_MONTH is 0

v_m1 = ELEMENT_NAME + ': '

/* ------------------------------------
Venit Brut Lunar din salarii
--------------------------------------- */
/*
v_VBL = TOTAL_BRUT_ASG_MONTH
if ASG_PRIMARY= 'Yes' and MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
v_VBL = TOTAL_BRUT_PER_MONTH
if ASG_PRIMARY= 'No' and MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
v_VBL = 0
*/

v_VBL = TOTAL_BRUT_ASG_MONTH
if MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
if MOD_ANGAJARE_DEDUCERE_ASSIGNMENT_S_ENTRY_VALUE = 'D'
then
(
if ASG_PRIMARY= 'Yes' then v_VBL = 0
if ASG_PRIMARY= 'No' then v_VBL = TOTAL_BRUT_ASG_MONTH
v_m1 = v_m1 + ': Deducere calculata la secundary assignment '

)
else
(
if ASG_PRIMARY= 'Yes' then v_VBL = TOTAL_BRUT_PER_MONTH
if ASG_PRIMARY= 'No' then v_VBL = 0
)

/* ------------------------------------
End: Venit Brut Lunar din salarii
--------------------------------------- */

/* ------------------------------------------------------------------
persoane in intretinere
------------------------------------------------------------------ */

v_nr_pers = COEF_DED_SUPLIM() / COEFICIENT_DEDUCERE_PERSOANA_INTRETINERE


if (v_nr_pers > NR_MAX_PERS_INTRETINERE) then v_nr_pers = NR_MAX_PERS_INTRETINERE

/* ------------------------------------------------------------------
End: persoane in intretinere
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Deducere personala
------------------------------------------------------------------ */
v_deducere = DEDUCERE_BAZA + DEDUCERE_DEPENDENT * v_nr_pers
if v_VBL = 0 then v_deducere = 0

if (v_VBL > VENIT_BRUT_1 and v_VBL <= VENIT_BRUT_3) then

v_deducere = roundup( (v_deducere * (1-( v_VBL - VENIT_BRUT_1)/ VENIT_BRUT_2))/ 100,1) * 100

/* ----------------
Exceptii
------------------- */

if
(CM_IMPOZIT_SCUTIRE_ASG_MONTH > 0) and
(v_VBL - CM_IMPOZIT_SCUTIRE_ASG_MONTH = 0) then
(
v_deducere = 0
v_m1 = v_m1 + ': Deducere=' + to_text(v_deducere) + ', Venit lunar impozabil este 0'
)

if (v_VBL > VENIT_BRUT_3) then v_deducere = 0

if ANGAJAT_IN_CURSUL_LUNII_ASG_RUN > 0 then


(
v_deducere = 0
v_m1 = v_m1 + ': Deducere=' + to_text(v_deducere) + ', Angajat in cursul lunii'
)

if MOD_ANGAJARE_FCT_BAZA_ALT_AGENT_ENTRY_VALUE = 'D' then


(
v_deducere = 0
v_m1 = v_m1 + ': Deducere=' + to_text(v_deducere) + ', cu functia de baza la alt agent'
)

/* salariat cetatean strain */


if MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'R'
or MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'N' then
(
v_deducere = 0
v_m1 = v_m1 + ': Deducere=' + to_text(v_deducere) + ', salariat cetatean strain '
)

if DEDUCERE_CORECTIE_ASG_RUN <> 0 then


(
v_deducere = v_deducere + DEDUCERE_CORECTIE_ASG_RUN
v_m1 = v_m1 + ': Deducere corectie=' + to_text(DEDUCERE_CORECTIE_ASG_RUN)
)

/* ----------------
End: Exceptii
------------------- */

/* ------------------------------------------------------------------
End: Deducere personala
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Cotizatie Sindicat
------------------------------------------------------------------ */

/* are cotizatie sindicat */


if (COTIZATIE_SINDICAT_COUNT > 0) then v_cotizatie_sindicat = COTIZATIE_SINDICAT_ASG_RUN

/* ------------------------------------------------------------------
End: Cotizatie Sindicat
------------------------------------------------------------------ */
v_m1 = v_m1 + ': Brut_A=' + to_text(TOTAL_BRUT_ASG_MONTH)
+ ', Brut_P=' + to_text(TOTAL_BRUT_PER_MONTH)
+ ', ASG_PRIMARY=' + ASG_PRIMARY

return
/* Deducere personala 1*/
v_deducere,
v_nr_pers,
v_cotizatie_sindicat,
v_m1

/* End: Formula: DEDUCERE_PERSONALA_1 */

DEFAULT_GROSSUP

/******************************************************************************
*
* Formula Name : DEFAULT_GROSSUP
*
* Description : This formula calculates the additional amount needed
* on top of a specified Net pay, that is need to reach tje
* the gross amount (before deductions).
*
* Change History
* --------------
*
* Who Date Description
* ---------- ---------- --------------------------------------------------
* N.Bristow 02-MAR-04 Added High Gross Factor.
* N.Bristow 24-NOV-99 Created.
*
*****************************************************************************/
default for low_gross is -999
default for high_gross is -999
default for additional_amount is -999
default for pay_value is -999
inputs are amount(number),
low_gross(number),
high_gross(number),
to_within(number),
additional_amount(number),
method(text),
pay_value(number)
stopper = 1
/* Do any initialisation needed */
if (low_gross = -999 or high_gross = -999) then
( if (low_gross = -999) then
low_gross = amount
if (high_gross = -999) then
(
gross_factor = ITERATION_GET_HIGH_GRS_FACTOR()
high_gross = amount*gross_factor
)

dummy = ITERATION_INITIALISE(high_gross, low_gross, amount)


/*
Now get the initial guess
*/
if method = 'INTERPOLATION' then
(
new_guess = ITERATION_GET_INTERPOLATION(0)
)
else
(
new_guess = ITERATION_GET_BINARY('INCREASE')
)
additional_amount = new_guess - amount

return low_gross, high_gross, additional_amount )


/* Heres the real processing */
grossup_balance = GROSSUP_AMOUNT
if (additional_amount = grossup_balance) then
return stopper
if (additional_amount + to_within >= grossup_balance
and additional_amount - to_within <= grossup_balance) then
(
remainder = additional_amount - grossup_balance
return remainder, stopper
)
/*
if (additional_amount + to_within >= grossup_balance) then
(
mesg = grossup_balance
remainder = additional_amount - grossup_balance
return remainder, stopper, grossup_balance
)
else
(
if (additional_amount - to_within <= grossup_balance) then
(
mesg = 2
remainder = additional_amount - grossup_balance
return remainder, stopper, mesg
)
)
*/

/* OK we have not found the correct value so we have to guess a new value */
if method = 'INTERPOLATION' then
(
changer = additional_amount - grossup_balance
new_guess = ITERATION_GET_INTERPOLATION(changer)
low_gross = ITERATION_GET_LOW()
high_gross = ITERATION_GET_HIGH()
additional_amount = new_guess - amount
additional_amount = round(additional_amount,2)
return additional_amount, low_gross, high_gross, grossup_balance, changer
)
else
(
/* It must be binary method */
if additional_amount < grossup_balance then
(
mesg = 'TO LOW Increasing'
new_guess = ITERATION_GET_BINARY('INCREASE')
)
else
(
mesg = 'TO HIGH reducing'
new_guess = ITERATION_GET_BINARY('REDUCE')
)

low_gross = ITERATION_GET_LOW()
high_gross = ITERATION_GET_HIGH()
additional_amount = new_guess - amount
return additional_amount, low_gross, high_gross, mesg, grossup_balance
)

DELEGATIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: DELEGATIE */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
default for Ora_inceput is 0
default for Ora_sfarsit is 0

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
Ora_inceput,
Ora_sfarsit

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')
/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
luna
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, DATA_SFARSIT )

v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)


/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile = v_z

v_ore = v_zile * v_durata_muncii


/* ---------------------------------------------------------------------------------------
End: luna
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
chenzina I
--------------------------------------------------------------------------------------- */
If (V_PLATA = 'C') then
( /* N 1 */
/* (1-15 ale lunii) */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)

v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)


v_data_sfarsit = least(v_d_15, DATA_SFARSIT)
v_zile_chenzina_I = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_chenzina_I = v_z

v_ore_chenzina_I = v_zile_chenzina_I * v_durata_muncii


) /* N 1 */
/* ---------------------------------------------------------------------------------------
End: chenzina I
--------------------------------------------------------------------------------------- */

/* stop
-----------------------------------------------------------------------------------*/
if (DATA_SFARSIT <= PAY_PROC_PERIOD_END_DATE) then
v_stop = 'Stop ' + ELEMENT_NAME

return
v_stop,

/* comune */
DATA_INCEPUT,
DATA_SFARSIT,
Ora_inceput,
Ora_sfarsit,

/* Delegatie Luna */
v_zile,
v_ore,

/* Delegatie chenzina I */
v_zile_chenzina_I ,
v_ore_chenzina_I

/* End: Formula: DELEGATIE */

EVENIMENTE_FAMILIALE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: EVENIMENTE_FAMILIALE */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
default for FEL is ' ' /* cod = xxZZ */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)
/* calcul luna */
default for PROCESARE_2_ASG_RUN is 0

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
FEL

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')
/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */
z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
Total zile
--------------------------------------------------------------------------------------- */
v_zile_drept = to_number(rtrim(substr(FEL,3,2)))
v_zile_t = GET_WORKING_DAYS(DATA_INCEPUT, DATA_SFARSIT)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = DATA_INCEPUT /* data inceput */
v_d_s = DATA_SFARSIT /* data sfarsit */
v_z = v_zile_t /* zilele ce vor fi corectate */
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_t = v_z

if (v_zile_t > v_zile_drept) then


(
v_m1 = 'Eroare ' + ELEMENT_NAME +
' Zile calculate ' + to_text(v_zile_t ) +
' >' + ' Zile drept ' + to_text(v_zile_drept)
return v_m1
)
/* ---------------------------------------------------------------------------------------
End: Total zile
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
luna
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, DATA_SFARSIT )

v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile = v_z

v_ore = v_zile * v_durata_muncii


/* ---------------------------------------------------------------------------------------
End: luna
--------------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
chenzina I
--------------------------------------------------------------------------------------- */
/* numai in Calcul avans */
if PROCESARE_1_ASG_RUN = 1 and
(v_plata = 'C') then
( /* N 1 */
/* (1-15 ale lunii) */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)

v_di_chenzina_I = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)


v_ds_chenzina_I = least(v_d_15, DATA_SFARSIT)
v_zile_chenzina_I = GET_WORKING_DAYS(v_di_chenzina_I, v_ds_chenzina_I)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_chenzina_I = v_z

v_ore_chenzina_I = v_zile_chenzina_I * v_durata_muncii


v_fel_chenzina_I = FEL
) /* N 1 */
/* ---------------------------------------------------------------------------------------
End: chenzina I
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
EV Indemnizatie
--------------------------------------------------------------------------------------- */
/* calcul luna */
if (PROCESARE_2_ASG_RUN = 1) then
(
v_ev_indemn_zile = v_zile
v_ev_indemn_ore = v_ore
)
/* ---------------------------------------------------------------------------------------
End: EV Indemnizatie
--------------------------------------------------------------------------------------- */

/* stop
-----------------------------------------------------------------------------------*/
if (DATA_SFARSIT <= PAY_PROC_PERIOD_END_DATE) then v_stop = ELEMENT_NAME + ' Stop '

return
v_stop,

/* comune */
DATA_INCEPUT,
DATA_SFARSIT,
FEL,

/* EV Luna */
v_zile,
v_ore,

/* EV chenzina I */
v_fel_chenzina_I,
v_zile_chenzina_I,
v_ore_chenzina_I,
v_di_chenzina_I,
v_ds_chenzina_I,

/* EV Indemnizatie */
v_ev_indemn_zile,
v_ev_indemn_ore

/* End: Formula: EVENIMENTE_FAMILIALE */

EV_INDEMNIZATIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: EV_INDEMNIZATIE */
default for ORE is 0

default for SALARIU_BAZA_ORAR_ASG_RUN is 0


/* procente spor */
default for PROCENT_SPOR_FIDELITATE_ASG_RUN is 0
default for PROCENT_SPOR_VECHIME_ASG_RUN is 0
default for ROT is 0
default for PROCENT_CN_ASG_MONTH is 0
default for PROCENT_CD_ASG_MONTH is 0
default for PROCENT_CS_ASG_MONTH is 0
default for ORE_CN_ASG_RUN is 0
default for ORE_CD_ASG_RUN is 0
default for ORE_CS_ASG_RUN is 0
/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0

inputs are
ORE

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3

v_sp_procente = PROCENT_SPOR_FIDELITATE_ASG_RUN
+ PROCENT_SPOR_VECHIME_ASG_RUN

v_indemn = round( SALARIU_BAZA_ORAR_ASG_RUN * (1 + v_sp_procente / 100) * ORE, ROT)

/* -------------------------------
Conditii de munca
------------------------------- */
baza = v_indemn
procent_cd = PROCENT_CD_ASG_MONTH
procent_cs = PROCENT_CS_ASG_MONTH

if v_cond_m = 1 then v_cs = baza


if v_cond_m = 2 then v_cd = baza
if v_cond_m = 3 then v_cn = baza

if ORE_CN_ASG_RUN <> 0
then
(
v_cd = round(baza * procent_cd / 100, ROT)
v_cs = round(baza * procent_cs / 100, ROT)
v_cn = baza - (v_cd + v_cs)
)
else if ORE_CD_ASG_RUN <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
v_cd = baza - (v_cs)
)
else if ORE_CS_ASG_RUN <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
)
/* -------------------------------
End: Conditii de munca
------------------------------- */

return
/* EV Indemnizatie */
v_indemn,
v_cn,
v_cd,
v_cs

/* End: Formula: EV_INDEMNIZATIE */

EXAMPLE_BIS_OT_BAND1

/*********************************************************************
FORMULA NAME: EXAMPLE_BIS_OT_BAND1
FORMULA TYPE: Quickpaint
DESCRIPTION: This is an example of the syntax required for the
fast formualae which need to be set up for use with
the Hours Worked Analysis Report. The function
get_hours_worked calculates total hours worked from
the Overtime element seeded with US Payroll.
--
INPUTS: None
--
DBI Required: None
--
Change History
--------------
Date Author Version Description
---- ------ ------- -----------
10 Sep 98 jmay 110.0 Created
--
16-SEP-98 mmillmor 110.2 Added a header
--
26 Nov 98 sbhattal 110.3 Create FastFormula type Quickpaint if it
does not exist (required for fresh HR databases
which have not had the HR post-install steps
applied, or for BIS customers who do not have
HR).
--
********************************************************************/

/* Updatable Values Section */

/* Defaults Section */

/* Inputs Section */

/* Main Body of Formula */


hours_worked = get_hours_worked(1.5)

RETURN hours_worked
FOAIE_PREZENTA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: FOAIE_PREZENTA */

default for ELEMENT_NAME is ' '

v_lansare = ELEMENT_NAME

return
/* Prezenta [prd] */
/* Prezenta saptamana [nr] */
v_lansare

/* End: Formula: FOAIE_PREZENTA */

FOND_CARTE_MUNCA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: FOND_CARTE_MUNCA v1 jan 06 */

default for FOND_CARTE_MUNCA_PROCENT is 0 /* 0.25 */


default for BAZA_SANATATE_ANGAJAT_ASG_MONTH is 0
default for PROFIT_ASG_MONTH is 0
default for TOTAL_PRESTATII_INTR_ASG_MONTH is 0
default for FACILITATI_SUPUSE_IMPOZITARII_ASG_MONTH is 0
default for CA_AGA_CENZ_ASG_MONTH is 0
default for INDEMNIZATIE_CA_NEREZIDENT_COUNT is 0
default for INDEMNIZATIE_CA_REZIDENT_COUNT is 0
default for ASG_EMPLOYMENT_CATEGORY_CODE is ' '

/* -------------------------------------------------------------------------
Baza
------------------------------------------------------------------------- */
v_baza =
BAZA_SANATATE_ANGAJAT_ASG_MONTH +
FACILITATI_SUPUSE_IMPOZITARII_ASG_MONTH+
TOTAL_PRESTATII_INTR_ASG_MONTH -
PROFIT_ASG_MONTH

if ASG_EMPLOYMENT_CATEGORY_CODE = 'CA_REZ' then


v_baza = v_baza - CA_AGA_CENZ_ASG_MONTH
/* -------------------------------------------------------------------------
End: Baza
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Contributie angajator
------------------------------------------------------------------------- */

v_contributie = round((FOND_CARTE_MUNCA_PROCENT / 100) * v_baza, 2)

v_nr_pers = 1
/* Consiliu Administratie */
if INDEMNIZATIE_CA_NEREZIDENT_COUNT > 0 or
INDEMNIZATIE_CA_REZIDENT_COUNT > 0 then v_nr_pers = 0

/* -------------------------------------------------------------------------
End: Contributie angajator
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Conta
------------------------------------------------------------------------- */

if v_contributie <> 0 then v_suma = v_contributie

/* -------------------------------------------------------------------------
End: Conta
------------------------------------------------------------------------- */

return
v_baza,
v_contributie,
v_nr_pers,

/* Conta Fond carte munca */


v_suma

/* End: Formula: FOND_CARTE_MUNCA */

GARANTIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: FOAIE_PREZENTA */

default for ELEMENT_NAME is ' '

v_lansare = ELEMENT_NAME
return
/* Prezenta [prd] */
/* Prezenta saptamana [nr] */
v_lansare

/* End: Formula: FOAIE_PREZENTA */

GARANTII

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: GARANTII */

default for GARANTII_ASG_MONTH is 0

v_garantii = GARANTII_ASG_MONTH

if (v_garantii <> 0) then v_suma = v_garantii

return v_garantii,

/* Conta garantii */

v_suma

/* End: Formula: GARANTII */

GRAFIC_CHENZINA_I
/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: GRAFIC_CHENZINA_I */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for EMP_HIRE_DATE is '01-FEB-2003' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Grafic chenzina I
--------------------------------------------------------------------------------------- */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14) /* (1-15 ale lunii) */
v_data_inceput = PAY_PROC_PERIOD_START_DATE
v_data_sfarsit = v_d_15
v_zile_lucratoare_chenzina_I = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)
/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_lucratoare_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_lucratoare_chenzina_I = v_z
v_ore_lucratoare_chenzina_I = v_zile_lucratoare_chenzina_I * v_durata_muncii
/* ---------------------------------------------------------------------------------------
End: Grafic chenzina I
--------------------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------
Grafic chenzina I corectii
--------------------------------------------------------------------------------------- */
v_Grafic_luna_c1 = 'N'

v_data_angajarii = MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE was defaulted)
then
v_data_angajarii = EMP_HIRE_DATE

v_data_terminarii = MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was defaulted)
then
v_data_terminarii = EMP_TERM_DATE

if (PAY_PROC_PERIOD_START_DATE < v_data_angajarii and v_data_angajarii <= v_d_15)


then
/* angajat in cursul chenzinei I >> Grafic chenzina I corectii
------------------------------------------------------ */
( /* N 1 */
v_Grafic_luna_c1 = 'Y'
v_d_angajarii = v_data_angajarii

v_data_inceput = PAY_PROC_PERIOD_START_DATE
v_data_sfarsit = ADD_DAYS(v_data_angajarii, -1)
v_zile_corectii = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_corectii /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_corectii = v_z
v_ore_corectii = v_zile_corectii * v_durata_muncii
) /* N 1 */

if (PAY_PROC_PERIOD_START_DATE < v_d_15) and


(v_d_15 < v_data_angajarii) and
(v_data_angajarii <= PAY_PROC_PERIOD_END_DATE)
then
/* angajat in cursul lunii, dar nu in chenzinei I >> Grafic chenzina I corectii
------------------------------------------------------ */
( /* N 3 */
v_Grafic_luna_c1 = 'Y'

v_data_inceput = PAY_PROC_PERIOD_START_DATE
v_data_sfarsit = v_d_15
v_zile_corectii = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_corectii /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_corectii = v_z
v_ore_corectii = v_zile_corectii * v_durata_muncii
) /* N 3 */

if
/* plecat in cursul Chenzinei I >> Grafic Chenzina I corectii */
(PAY_PROC_PERIOD_START_DATE <= v_data_terminarii and v_data_terminarii < v_d_15) or
/* plecat intr-o luna anterioara >> Grafic Chenzina I corectii */
(v_data_terminarii < PAY_PROC_PERIOD_START_DATE)
then
( /* N 2 */
v_data_inceput = greatest(ADD_DAYS(v_data_terminarii, 1), PAY_PROC_PERIOD_START_DATE)
v_data_sfarsit = v_d_15
v_d_plecarii = v_data_terminarii

if (v_Grafic_luna_c1 = 'Y')
then
v_zile_corectii = v_zile_corectii + GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)
else
v_zile_corectii = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_corectii /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_corectii = v_z
v_ore_corectii = v_zile_corectii * v_durata_muncii
) /* N 2 */
/* --------------------------------------------------------------------------------------
End: Grafic chenzina I corectii
--------------------------------------------------------------------------------------- */
return
/* Grafic chenzina I */
v_zile_lucratoare_chenzina_I,
v_ore_lucratoare_chenzina_I,

/* Grafic chenzina I corectii */


v_d_angajarii,
v_d_plecarii,
v_zile_corectii,
v_ore_corectii

/* End: Formula: GRAFIC_CHENZINA_I */

GRAFIC_LUNA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: GRAFIC_LUNA */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for EMP_HIRE_DATE is '01-FEB-2003' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)
/* transfer intre subunitati */
default for ASG_DATE_FROM is '01-FEB-1900' (date)
default for ASG_DATE_TO is '01-FEB-4700' (date)
default for ASG_STATUS is ' '
default for ASG_START_DATE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------
Grafic luna
--------------------------------------------------------------------------------------- */
v_data_inceput = PAY_PROC_PERIOD_START_DATE
v_data_sfarsit = PAY_PROC_PERIOD_END_DATE
v_zile_lucratoare_luna = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_lucratoare_luna /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_lucratoare_luna = v_z
v_ore_lucratoare_luna = v_zile_lucratoare_luna * v_durata_muncii
/* ---------------------------------------------------------------------------------------
End: Grafic luna
--------------------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------
Grafic luna corectii
--------------------------------------------------------------------------------------- */
v_Grafic_luna_c1 = 'N'

v_data_angajarii = MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_angajarii = EMP_HIRE_DATE

v_data_terminarii = MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was defaulted) then
v_data_terminarii = EMP_TERM_DATE

/* transfer intre subunitati */


if MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T' then
(
v_asg_i = ASG_DATE_FROM
if ASG_STATUS = 'Terminate Assignment' then v_asg_i = ASG_START_DATE
v_data_angajarii = greatest(v_data_angajarii, v_asg_i)

v_asg_s = ASG_DATE_TO
if ASG_STATUS = 'Terminate Assignment' then v_asg_s = ADD_DAYS(ASG_DATE_FROM, -1)
v_data_terminarii = least(v_data_terminarii, v_asg_s)
)

if (PAY_PROC_PERIOD_START_DATE < v_data_angajarii and v_data_angajarii <=


PAY_PROC_PERIOD_END_DATE)
then
/* angajat in cursul lunii >> Grafic luna corectii
------------------------------------------------------ */
( /* N 1 */
v_Grafic_luna_c1 = 'Y'
v_d_angajarii = v_data_angajarii

v_data_inceput = PAY_PROC_PERIOD_START_DATE
v_data_sfarsit = ADD_DAYS(v_data_angajarii, -1)
v_zile_corectii_luna = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_corectii_luna /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_corectii_luna = v_z
v_ore_corectii_luna = v_zile_corectii_luna * v_durata_muncii
if v_zile_corectii_luna > 0 and NOT (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'T') then v_angajat
=1
) /* N 1 */

if
/* plecat in cursul lunii >> Grafic luna corectii */
((PAY_PROC_PERIOD_START_DATE <= v_data_terminarii and
v_data_terminarii < PAY_PROC_PERIOD_END_DATE)) or
/* plecat intr-o luna anterioara >> Grafic luna corectii */
(v_data_terminarii < PAY_PROC_PERIOD_START_DATE)
then
( /* N 2 */
v_data_inceput = greatest(ADD_DAYS(v_data_terminarii, 1), PAY_PROC_PERIOD_START_DATE)
v_data_sfarsit = PAY_PROC_PERIOD_END_DATE
v_d_plecarii = v_data_terminarii

if (v_Grafic_luna_c1 = 'Y')
then
v_zile_corectii_luna = v_zile_corectii_luna + GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)
else
v_zile_corectii_luna = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_corectii_luna /* zilele ce vor fi corectate */
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_corectii_luna = v_z
v_ore_corectii_luna = v_zile_corectii_luna * v_durata_muncii
) /* N 2 */
/* --------------------------------------------------------------------------------------
End: Grafic luna corectii
--------------------------------------------------------------------------------------- */

return
/* Grafic luna */
v_zile_lucratoare_luna,
v_ore_lucratoare_luna,

/* Grafic luna corectii */


v_zile_corectii_luna,
v_ore_corectii_luna,
v_d_angajarii,
v_d_plecarii,

/* Angajat in cursul lunii */


v_angajat

/* End: Formula: GRAFIC_LUNA */

GRAFIC_LUNA_CORECTII

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: GRAFIC_LUNA_CORECTII */

default for DATA_ANGAJARII is '01-FEB-2000' (date)


default for DATA_PLECARII is '01-FEB-4000' (date)

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_ANGAJARII,
DATA_PLECARII

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')
/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_nr_ore = v_durata_muncii
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Liber zi
--------------------------------------------------------------------------------------- */
v_data_inceput = ADD_DAYS(DATA_ANGAJARII, -1)
v_data_sfarsit = ADD_DAYS(DATA_PLECARII, 1)

/* zi 1
------------------------------------------------------------------------*/
v_zi = PAY_PROC_PERIOD_START_DATE

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_1 = v_nr_ore
)

/* zi 2
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_2 = v_nr_ore
)

/* zi 3
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_3 = v_nr_ore
)

/* zi 4
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
/* este in perioada de Liber */
if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_4 = v_nr_ore
)

/* zi 5
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_5 = v_nr_ore
)

/* zi 6
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_6 = v_nr_ore
)

/* zi 7
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_7 = v_nr_ore
)

/* zi 8
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_8 = v_nr_ore
)

/* zi 9
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_9 = v_nr_ore
)

/* zi 10
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_10 = v_nr_ore
)

/* zi 11
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_11 = v_nr_ore
)

/* zi 12
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_12 = v_nr_ore
)

/* zi 13
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_13 = v_nr_ore
)

/* zi 14
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_14 = v_nr_ore
)

/* zi 15
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_15 = v_nr_ore
)

/* zi 16
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_16 = v_nr_ore
)

/* zi 17
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_17 = v_nr_ore
)

/* zi 18
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_18 = v_nr_ore
)

/* zi 19
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
/* este in perioada de Liber */
if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_19 = v_nr_ore
)

/* zi 20
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_20 = v_nr_ore
)

/* zi 21
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_21 = v_nr_ore
)

/* zi 22
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
/* este in perioada de Liber */
if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_22 = v_nr_ore
)

/* zi 23
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_23 = v_nr_ore
)

/* zi 24
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_24 = v_nr_ore
)

/* zi 25
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
/* este in perioada de Liber */
if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_25 = v_nr_ore
)

/* zi 26
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_26 = v_nr_ore
)

/* zi 27
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_27 = v_nr_ore
)

/* zi 28
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
/* este in perioada de Liber */
if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_28 = v_nr_ore
)

/* zi 29
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_29 = v_nr_ore
)

/* zi 30
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_30 = v_nr_ore
)

/* zi 31
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de Liber */


if (PAY_PROC_PERIOD_START_DATE <= v_zi and v_zi <= v_data_inceput) or
(v_data_sfarsit <= v_zi and v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_31 = v_nr_ore
)
/* ---------------------------------------------------------------------------------------
End: Liber zi
--------------------------------------------------------------------------------------- */

return
/* Liber zi [nr] */
v_tn_1,
v_tn_2,
v_tn_3,
v_tn_4,
v_tn_5,
v_tn_6,
v_tn_7,
v_tn_8,
v_tn_9,
v_tn_10,
v_tn_11,
v_tn_12,
v_tn_13,
v_tn_14,
v_tn_15,
v_tn_16,
v_tn_17,
v_tn_18,
v_tn_19,
v_tn_20,
v_tn_21,
v_tn_22,
v_tn_23,
v_tn_24,
v_tn_25,
v_tn_26,
v_tn_27,
v_tn_28,
v_tn_29,
v_tn_30,
v_tn_31

/* End: Formula: GRAFIC_LUNA_CORECTII */

IMPOZIT_CORECTII

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: IMPOZIT_CORECTII */

default for REGULARIZARE is 0

inputs are REGULARIZARE

v_regularizare = REGULARIZARE

/* ---------------------------------------------------------------------------------------

Conta

--------------------------------------------------------------------------------------- */
/* Conta Impozit restituit */

if (v_regularizare < 0) then v_suma_r = (-1) * v_regularizare

/* Conta Impozit de plata*/

if (v_regularizare > 0) then v_suma_p = v_regularizare

/* ---------------------------------------------------------------------------------------

End: Conta

--------------------------------------------------------------------------------------- */

return

v_regularizare,

/* Conta Impozit restituit */

v_suma_r,

/* Conta Impozit de plata*/

v_suma_p

/* End: Formula: IMPOZIT_CORECTII */

IMPUTATIE_RETINERE_1

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: IMPUTATIE_RETINERE_1 */

default for REST_PLATA_2_ASG_PTD is 0


default for IMPUTATIE_1_ASG_ITD is 0
default for IMPUTATIE_NEACOPERIT_1_ASG_ITD is 0
default for RATA is 0
default for ELEMENT_NAME is ' '

inputs are RATA

v_disponibil = REST_PLATA_2_ASG_PTD
v_rata = RATA
v_neacoperit_initial = IMPUTATIE_NEACOPERIT_1_ASG_ITD
v_rest_plata = IMPUTATIE_1_ASG_ITD

v_rata_de_platit = least(v_rata + v_neacoperit_initial,v_rest_plata)

v_rata_retinuta = least(v_disponibil,v_rata_de_platit)

v_neacoperit_final = v_rata_de_platit - v_rata_retinuta


if (v_neacoperit_final > 0) then v_mesaj_1 = 'Atentie: ' + ELEMENT_NAME +
' : Retinere neacoperita = ' + to_text(v_neacoperit_final)

v_rest_plata = v_rest_plata - v_rata_retinuta

if (v_rest_plata > 0) then

return v_neacoperit_initial,
v_neacoperit_final,
v_rata_retinuta,
v_rest_plata,
v_mesaj_1

else
(
v_stop = ELEMENT_NAME + ' Stop '

return v_neacoperit_initial,
v_neacoperit_final,
v_rata_retinuta,
v_rest_plata,
v_mesaj_1,
v_stop
)

/* End: Formula: IMPUTATIE_RETINERE_1 */

IMPUTATII

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *


* *

******************************************************************/

/* Formula: IMPUTATII */

default for IMPUTATII_ASG_MONTH is 0

v_imputatii = IMPUTATII_ASG_MONTH

if (v_imputatii <> 0) then v_suma = v_imputatii

return v_imputatii,

/* Conta imputatii */

v_suma

/* End: Formula: IMPUTATII */

INDEMNIZATIE_CO

/******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: INDEMNIZATIE_CO */

default for ZILE is 0


default for ZILE_TOTAL is 0
default for AVANS is 0
default for PROCENT is 0
default for INDEMNIZATIE_ZI is 0

default for VENITURI_ANTERIOARE_CO_ASG_RUN is 0


default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0
default for SALARIU_BAZA_LUNAR_ASG_RUN is 0
default for SPORURI_NEGOCIATE_PROCENTE_ASG_RUN is 0
default for ELEMENT_NAME is ' '

default for PROCENT_SPOR_VECHIME_ASG_RUN is 0


default for PROCENT_SPOR_FIDELITATE_ASG_RUN is 0
default for INDEMNIZATIE_CONDUCERE_ASG_RUN is 0
default for INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN is 0
default for ROT is 0
default for PROCENT_AVANS_CO is 0
default for PROCENT_CN_ASG_MONTH is 0
default for PROCENT_CD_ASG_MONTH is 0
default for PROCENT_CS_ASG_MONTH is 0
default for ORE_CN_ASG_MONTH is 0
default for ORE_CD_ASG_MONTH is 0
default for ORE_CS_ASG_MONTH is 0
/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0

default for CAS_ASIGURAT is 0 /* 9.5 */


default for PROCENT_IMPOZIT_SAL is 0 /* 16 */
default for SANATATE_ASIGURAT is 0 /* 6.5 */
default for PROC_SOMAJ_ASIG is 0 /* 0.01 */

inputs are
ZILE,
ZILE_TOTAL,
AVANS,
PROCENT,
INDEMNIZATIE_ZI

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3

v_p_vechime = PROCENT_SPOR_VECHIME_ASG_RUN
v_p_fidelitate = PROCENT_SPOR_FIDELITATE_ASG_RUN
v_vn_ant = VENITURI_ANTERIOARE_CO_ASG_RUN
v_id_fsupl = INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN
v_id_conducere = INDEMNIZATIE_CONDUCERE_ASG_RUN

v_sp_procente = SPORURI_NEGOCIATE_PROCENTE_ASG_RUN
v_sal = SALARIU_BAZA_LUNAR_ASG_RUN
v_z_lucratoare_lu = ZILE_LUCRATOARE_LUNA_ASG_RUN
if v_z_lucratoare_lu = 0 then
(
v_m1 = ELEMENT_NAME + ': Zile lucratoare luna=' + to_text(v_z_lucratoare_lu)
return v_m1
)

/* ----------------------------------------------------------------------------
indemnizatie calculata pe baza datelor lunii curente
----------------------------------------------------------------------------- */
y = v_sal * (1 + v_sp_procente /100) + v_id_fsupl + v_id_conducere
v_i_co_c = y / v_z_lucratoare_lu
/*v_i_co_c = round(y / v_z_lucratoare_lu * ZILE)*/

/* ----------------------------------------------------------------------------
indemnizatie calculata pe baza mediei ultimelor 3 luni
----------------------------------------------------------------------------- */
y = v_sal * (1 + v_p_vechime/100 + v_p_fidelitate/100) + (v_vn_ant / 3)
v_i_co_m = y / v_z_lucratoare_lu
/*v_i_co_m = round((y / v_z_lucratoare_lu) * ZILE )*/

/* ----------------------------------------------------------------------------
indemnizatie (max)
----------------------------------------------------------------------------- */
v_indemnizatie_co_zi = greatest(v_i_co_c, v_i_co_m)
v_indemnizatie_co = round(v_indemnizatie_co_zi * ZILE )
/*v_indemnizatie_co = greatest(v_i_co_c, v_i_co_m)*/
if INDEMNIZATIE_ZI was not defaulted then v_indemnizatie_co = round(INDEMNIZATIE_ZI * ZILE )

/* ------------------------------------
Avans CO acordat
--------------------------------------- */
if ZILE_TOTAL > 0 then
( /* N 1 */
v_pr = PROCENT_AVANS_CO
v_indemnizatie_co_t = round(v_indemnizatie_co_zi * ZILE_TOTAL)

av_SOM = round((v_sal / v_z_lucratoare_lu) * ZILE * PROC_SOMAJ_ASIG)


av_CAS = round(v_indemnizatie_co_t * CAS_ASIGURAT / 100)
av_SAN = round(v_indemnizatie_co_t * SANATATE_ASIGURAT / 100)
y = v_indemnizatie_co_t - (av_SOM + av_CAS + av_SAN)
av_IMP = round(y * PROCENT_IMPOZIT_SAL / 100)

/*retineri de luna trecuta - medie pe zi*/


v_retineri = greatest(0,to_num(ELEMENT_HISTORY('RETINERI','PAY VALUE',1)))
v_retineri_zi = v_retineri / v_z_lucratoare_lu

av_RET = round(v_retineri_zi * ZILE_TOTAL)

v_av = round(v_indemnizatie_co_t - (av_SOM + av_CAS + av_SAN + av_IMP + av_RET), -1)

if PROCENT was not defaulted then


(
v_pr = PROCENT
y = round(v_indemnizatie_co_t, -2)
v_av = round(y * v_pr / 100, ROT)
)
if AVANS was not defaulted then v_av = AVANS
) /* N 1 */
/* ------------------------------------
End: Avans CO acordat
--------------------------------------- */

/* -------------------------------
Conditii de munca
------------------------------- */
baza = v_indemnizatie_co
procent_cd = PROCENT_CD_ASG_MONTH
procent_cs = PROCENT_CS_ASG_MONTH

if v_cond_m = 1 then v_cs = baza


if v_cond_m = 2 then v_cd = baza
if v_cond_m = 3 then v_cn = baza

if ORE_CN_ASG_MONTH <> 0
then
(
v_cd = round(baza * procent_cd / 100, ROT)
v_cs = round(baza * procent_cs / 100, ROT)
v_cn = baza - (v_cd + v_cs)
)
else if ORE_CD_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
v_cd = baza - (v_cs)
)
else if ORE_CS_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
)
/* -------------------------------
End: Conditii de munca
------------------------------- */

return
v_indemnizatie_co,
v_cn, /*CN*/
v_cd,
v_cs,

/* Avans CO [nr] acordat */


v_av

/* End: Formula: INDEMNIZATIE_CO */

INDEMNIZATIE_INVALIDITATE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: INDEMNIZATIE_INVALIDITATE */

default for NR_SALARII is ' '


default for SUMA is 0
default for ACORDAT_IN_AVANS is 'D'
default for AVANS is 0
default for Data_plata is '01-FEB-1900' (DATE)
default for SALARIU_LUNAR_UNITATE is 0
default for Data_accident is '01-FEB-1900' (DATE)

default for ELEMENT_NAME is ' '


default for PLAFON_VENIT_NEIMPOZABIL is 0
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)

inputs are
NR_SALARII,
SUMA,
ACORDAT_IN_AVANS,
AVANS,
Data_plata,
SALARIU_LUNAR_UNITATE,
Data_accident

/* --------------------------
Suma
--------------------------- */

v_suma = SUMA
if SUMA was defaulted then
(
v_sal_u = SALARIU_LUNAR_UNITATE
if SALARIU_LUNAR_UNITATE was defaulted then
(
eff_date = Data_accident
if Data_accident was defaulted then eff_date = PAY_PROC_PERIOD_START_DATE
v_sal_u = to_num(GET_TABLE_VALUE('Salariu lunar unitate', 'Valoare', '1', eff_date))
)
v_suma = v_sal_u * to_num(NR_SALARII)
)
/* --------------------------
End: Suma
--------------------------- */

/* --------------------------
avans
----------------------------- */

if ACORDAT_IN_AVANS = 'D' then


(
v_lansare_avans = ELEMENT_NAME
v_data_plata = DATA_PLATA
if DATA_PLATA was defaulted then v_data_plata = PAY_PROC_PERIOD_START_DATE
v_avans = v_suma
if AVANS was not defaulted then v_avans = AVANS
)

/* --------------------------
end: avans
----------------------------- */

return
v_suma,
v_sal_u,
/* Avans Indemnizatie invaliditate */
v_avans, /* Conta Acordare avans salarial */ /* Conta Avans salarial */
v_data_plata, /* Conta Acordare avans salarial */
v_lansare_avans

/* End: Formula: INDEMNIZATIE_INVALIDITATE */

INDEMNIZATIE_PENSIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: INDEMNIZATIE_PENSIE */

default for NR_SALARII is ' '


default for SUMA is 0
default for ACORDAT_IN_AVANS is 'D'
default for AVANS is 0
default for Data_plata is '01-FEB-1900' (DATE)
default for SALARIU is 0

default for ELEMENT_NAME is ' '


default for PLAFON_VENIT_NEIMPOZABIL is 0
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)
default for SALARIU_BAZA_LUNAR_ASG_RUN is 0

inputs are
NR_SALARII,
SUMA,
ACORDAT_IN_AVANS,
AVANS,
Data_plata,
SALARIU

/* --------------------------
Suma
--------------------------- */

v_suma = SUMA
if SUMA was defaulted then
(
v_sal = SALARIU_BAZA_LUNAR_ASG_RUN
if SALARIU was not defaulted then v_sal = SALARIU
v_suma = v_sal * to_num(NR_SALARII)
)
/* --------------------------
End: Suma
--------------------------- */

/* --------------------------
avans
----------------------------- */
if ACORDAT_IN_AVANS = 'D' then
(
v_lansare_avans = ELEMENT_NAME
v_data_plata = DATA_PLATA
if DATA_PLATA was defaulted then v_data_plata = PAY_PROC_PERIOD_START_DATE
v_avans = v_suma
if AVANS was not defaulted then v_avans = AVANS
)

/* --------------------------
end: avans
----------------------------- */

return
v_suma,
v_sal,
/* Avans Indemnizatie pensie */
v_avans, /* Conta Acordare avans salarial */ /* Conta Avans salarial */
v_data_plata, /* Conta Acordare avans salarial */
v_lansare_avans

/* End: Formula: INDEMNIZATIE_PENSIE */

INDEMNIZATII

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: INDEMNIZATII */

default for INDEMNIZATII_ASG_MONTH is 0

v_indemnizatii = INDEMNIZATII_ASG_MONTH

if (v_indemnizatii <> 0) then v_suma = v_indemnizatii


return v_indemnizatii,

/* Conta indemnizatii */

v_suma

/* End: Formula: INDEMNIZATII */

IND_CA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: IND_CA */

default for INDEMNIZATIE is 0


default for VARIANTA_NEGOCIERE is ' '
default for MONEDA is ' '

default for ASG_EMPLOYMENT_CATEGORY_CODE is ' '


default for SANATATE_ASIGURAT is 0
default for PROCENT_IMPOZIT_SAL is 0
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)
default for ELEMENT_NAME is ' '

inputs are
INDEMNIZATIE,
VARIANTA_NEGOCIERE,
MONEDA

v_venit_brut = 0
v_indemnizatie = INDEMNIZATIE
v_negociere = VARIANTA_NEGOCIERE
v_moneda = MONEDA
eff_date = PAY_PROC_PERIOD_START_DATE
v_curs_valutar = to_number(GET_TABLE_VALUE('Curs valutar', 'Valoare', v_moneda, eff_date))
v_indemnizatie = v_indemnizatie * v_curs_valutar

if ( v_negociere = 'BRUT' )
then v_venit_brut = v_indemnizatie
else

/* -------------------------------------------------------------------------
Calcul de la NET la BRUT
------------------------------------------------------------------------- */
(
NET = v_indemnizatie

IMP = PROCENT_IMPOZIT_SAL / 100


SAN = SANATATE_ASIGURAT / 100

if ASG_EMPLOYMENT_CATEGORY_CODE = 'CA_NREZ'
then
v_venit_brut = round (NET / (1 - IMP))
else
if ASG_EMPLOYMENT_CATEGORY_CODE = 'CA_REZ'
then
v_venit_brut = round (NET / ((1 - SAN) * (1 - IMP)))
else
v_mesaj_eroare = ELEMENT_NAME + 'Nu este membru CA'
)
/* -------------------------------------------------------------------------
End : Calcul de la NET la BRUT
------------------------------------------------------------------------- */

return
v_venit_brut,
v_mesaj_eroare

/* End: Formula: IND_CA */

NI_VALIDATION
inputs are national_identifier (text)

invalid_mesg = 'HR_7056_EMP_INVALID_SS_NO'

return_value = chk_nat_id_format(national_identifier,'DDDDDDDDDDDDD')

v_c1 = to_number(substr(national_identifier, 1, 1))

v_c2 = to_number(substr(national_identifier, 2, 1))

v_c3 = to_number(substr(national_identifier, 3, 1))

v_c4 = to_number(substr(national_identifier, 4, 1))

v_c5 = to_number(substr(national_identifier, 5, 1))

v_c6 = to_number(substr(national_identifier, 6, 1))

v_c7 = to_number(substr(national_identifier, 7, 1))

v_c8 = to_number(substr(national_identifier, 8, 1))


v_c9 = to_number(substr(national_identifier, 9, 1))

v_c10 = to_number(substr(national_identifier, 10, 1))

v_c11 = to_number(substr(national_identifier, 11, 1))

v_c12 = to_number(substr(national_identifier, 12, 1))

v_c13 = to_number(substr(national_identifier, 13, 1))

v_s = v_c1*2 + v_c2*7 + v_c3*9 + v_c4 + v_c5*4 + v_c6*6 +

v_c7*3 + v_c8*5 + v_c9*8 + v_c10*2 + v_c11*7 + v_c12*9

v_x = floor(v_s / 11)

v_rest = v_s - v_x*11

if (v_rest = 10) then v_rest = 1

if (v_rest<>v_c13) then

return_value = 'INVALID_ID'

invalid_mesg = 'CNP incorect'

if return_value = '0' then

return_value = 'INVALID_ID'

return return_value,invalid_mesg

ONCE_EACH_PERIOD

process_this_period = ENTRY_PROCESSED_IN_PERIOD()

if process_this_period = 'Y'
then Skip_flag = 'Y'

else Skip_flag = 'N'

return Skip_flag

ORE_IN_CONDITII_DE_MUNCA

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: ORE_IN_CONDITII_DE_MUNCA */

default for NORMALE is 0


default for DEOSEBITE is 0
default for SPECIALE is 0

/* coduri lookup
1 = CS
2 = CD
3 = CN
*/

/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 0
default for ELEMENT_NAME is ' '

inputs are
NORMALE,
DEOSEBITE,
SPECIALE

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3

o_cn = NORMALE
o_cd = DEOSEBITE
o_cs = SPECIALE
o_t = o_cn + o_cd + o_cs

if o_t <> ORE_LUCRATOARE_LUNA_ASG_RUN then


(
v_m1 = ELEMENT_NAME + ': Total ore eronat '

if v_cond_m = 3 then
(
o_cn = ORE_LUCRATOARE_LUNA_ASG_RUN - (o_cd + o_cs)
v_m1 = ELEMENT_NAME + ': Ore CN corectat la ' + to_text(o_cn)
)
if v_cond_m = 2 then
(
o_cd = ORE_LUCRATOARE_LUNA_ASG_RUN - (o_cn + o_cs)
v_m1 = ELEMENT_NAME + ': Ore CD corectat la ' + to_text(o_cd)
)

if v_cond_m = 1 then
(
o_cs = ORE_LUCRATOARE_LUNA_ASG_RUN - (o_cn + o_cd)
v_m1 = ELEMENT_NAME + ': Ore CS corectat la ' + to_text(o_cs)
)

o_t = o_cn + o_cd + o_cs


)

pr_cn = o_cn / o_t *100


pr_cd = o_cd / o_t *100
pr_cs = o_cs / o_t *100

return
o_cn,
o_cd,
o_cs,
o_t, /* PV */
pr_cn,
pr_cd,
pr_cs,

v_m1

/* End: Formula: ORE_IN_CONDITII_DE_MUNCA */

PARTICIPARE_PROFIT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PARTICIPARE_PROFIT */

default for SUMA is 0


default for ACORDAT_IN_AVANS is 'D'
default for AVANS is 0
default for Data_plata is '01-FEB-1900' (DATE)
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)

inputs are
SUMA,
ACORDAT_IN_AVANS,
AVANS,
Data_plata
/* --------------------------
Suma
--------------------------- */

v_suma = SUMA

/* --------------------------
End: Suma
--------------------------- */

/* --------------------------
avans
----------------------------- */

if ACORDAT_IN_AVANS = 'D' then


(
v_lansare_avans = ELEMENT_NAME
v_data_plata = DATA_PLATA
if DATA_PLATA was defaulted then v_data_plata = PAY_PROC_PERIOD_START_DATE
v_avans = v_suma
if AVANS was not defaulted then v_avans = AVANS
)

/* --------------------------
end: avans
----------------------------- */

return
v_suma,
/* Avans Participare profit */
v_avans, /* Conta Acordare avans salarial */ /* Conta Avans salarial */
v_data_plata, /* Conta Acordare avans salarial */
v_lansare_avans

/* End: Formula: PARTICIPARE_PROFIT */

PENSIE_ALIMENTARA

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/
/* Formula: PENSIE_ALIMENTARA */

default for PENSIE_ALIMENTARA_ASG_MONTH is 0

v_pensie_alimentara = PENSIE_ALIMENTARA_ASG_MONTH

if (v_pensie_alimentara <> 0) then v_suma = v_pensie_alimentara

return v_pensie_alimentara,

/* Conta Pensii alimentare */

v_suma

/* End: Formula: PENSIE_ALIMENTARA */

PENSIE_ALIMENTARA_1

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PENSIE_ALIMENTARA_1

v1 AUG 05 >> s-a modificat algoritmul de calcul al taxei postale


*/

default for REST_PLATA_2_ASG_MONTH is 0


default for SALARIU_NET_ASG_MONTH is 0
default for PENSIE_ALIMENTARA_1_NEACOPERIT_ASG_ITD is 0

default for RATA is 0


default for PROCENT is 0
default for CALCUL_TAXA is ' '
default for TAXA is 0

/* taxa postala */
default for TAXA_P_VAL1 is 0 /* 3.000 */
default for TAXA_P_PROC2 is 0 /* 0.01 */
default for ELEMENT_NAME is ' '

inputs are
RATA,
PROCENT,
CALCUL_TAXA,
TAXA

/***
***
am considerat ca
v_neacoperit = v_neacoperit_initial
v_neacoperit_curent = v_neacoperit_final
si ca sa transfer neacoperitul de la o luna la alta
in fiecare luna fac operatiile:
scad neacoperitul initial si astfel devine zero neacoperitul
adaug neacoperitul curent ca sa il transfer luna urmatoare
***
***/

v_disponibil = REST_PLATA_2_ASG_MONTH
v_rata_fixa = RATA
v_neacoperit = PENSIE_ALIMENTARA_1_NEACOPERIT_ASG_ITD
v_rata_retinuta = 0
v_taxa_retinuta = 0
v_retinere_totala = 0

v_rata = 0
if (RATA was defaulted)
then
v_rata = round((PROCENT) * (SALARIU_NET_ASG_MONTH ),0)
else
v_rata = RATA

v_taxa = 0
if (TAXA was defaulted) then
(
/* ---------------------------------------------------------------------------------------
taxa postala
--------------------------------------------------------------------------------------- */
if (CALCUL_TAXA = 'D') then
(
/* taxa trebuie calculata si la neacoperit */
v_taxa = round(TAXA_P_VAL1 /*3.000*/ + (v_rata + v_neacoperit) * TAXA_P_PROC2 /* 0.01 */, 2)
)

v_rata_de_platit = (v_rata + v_neacoperit + v_taxa)

if (v_disponibil >= v_rata_de_platit) then


(v_rata_retinuta = v_rata + v_neacoperit
v_taxa_retinuta = v_taxa
v_retinere_totala = v_rata_de_platit)
)
/* ---------------------------------------------------------------------------------------
End: taxa postala
--------------------------------------------------------------------------------------- */

/* neacoperit nu trebuie sa includa si taxa precalculata */


v_neacoperit_curent = greatest((v_rata + v_neacoperit) - v_retinere_totala, 0)

if (v_neacoperit_curent > 0) then


v_mesaj_1 = 'Atentie: ' + ELEMENT_NAME + ' : Retinere neacoperita = ' + to_text(v_neacoperit_curent)

return
v_neacoperit,
v_neacoperit_curent,
v_rata_retinuta,
v_taxa_retinuta,
v_retinere_totala,
v_mesaj_1

/* End: Formula: PENSIE_ALIMENTARA_1 */

POPRIRE_AVANS_1

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: POPRIRE_AVANS_1 */

default for SUMA is 0

default for POPRIRE_1_ASG_ITD is 0

default for ELEMENT_NAME is ' '

inputs are SUMA

v_suma = SUMA

/* -----------------
Poprire
----------------- */
v_rest_plata = POPRIRE_1_ASG_ITD
v_suma = least(v_suma,v_rest_plata)
/* -----------------
End: Poprire
----------------- */

return
v_suma

/* End: Formula: POPRIRE_AVANS_1 */


POPRIRE_RATE

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: POPRIRE_RATE */

default for IAN is 0


default for FEB is 0
default for MAR is 0
default for APR is 0
default for MAI is 0
default for IUN is 0
default for IUL is 0
default for AUG is 0
default for SEP is 0
default for OCT is 0
default for NOI is 0
default for DEC is 0
default for RATA is 0

default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)

inputs are
IAN,
FEB,
MAR,
APR,
MAI,
IUN,
IUL,
AUG,
SEP,
OCT,
NOI,
DEC,
RATA

v_rata = RATA
if RATA was defaulted then
(
v_luna_curenta = to_number(substr(to_text(PAY_PROC_PERIOD_START_DATE),6,2))

if v_luna_curenta = 1 and IAN was not defaulted then v_rata = IAN


if v_luna_curenta = 2 and FEB was not defaulted then v_rata = FEB
if v_luna_curenta = 3 and MAR was not defaulted then v_rata = MAR
if v_luna_curenta = 4 and APR was not defaulted then v_rata = APR
if v_luna_curenta = 5 and MAI was not defaulted then v_rata = MAI
if v_luna_curenta = 6 and IUN was not defaulted then v_rata = IUN
if v_luna_curenta = 7 and IUL was not defaulted then v_rata = IUL
if v_luna_curenta = 8 and AUG was not defaulted then v_rata = AUG
if v_luna_curenta = 9 and SEP was not defaulted then v_rata = SEP
if v_luna_curenta = 10 and OCT was not defaulted then v_rata = OCT
if v_luna_curenta = 11 and NOI was not defaulted then v_rata = NOI
if v_luna_curenta = 12 and DEC was not defaulted then v_rata = DEC
)

return
v_rata /* PV */

/* End: Formula: POPRIRE_RATE */

POPRIRE_RATE_LUNA

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: POPRIRE_RATE_LUNA */

default for REST_PLATA_2_ASG_MONTH is 0


default for POPRIRE_RATE_LUNA_ASG_RUN is 0
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)

v_pr = 100
v_rate = POPRIRE_RATE_LUNA_ASG_RUN
v_disp = REST_PLATA_2_ASG_MONTH

if v_rate > v_disp then v_pr = v_disp / v_rate *100

return
v_rate, /* PV */
v_pr,
v_disp

/* End: Formula: POPRIRE_RATE_LUNA */

POPRIRE_RETINERE_1

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: POPRIRE_RETINERE_1 */

default for REST_PLATA_2_ASG_MONTH is 0

default for POPRIRE_1_ASG_ITD is 0


default for POPRIRE_NEACOPERIT_1_ASG_ITD is 0
default for POPRIRE_RATE_LUNA_PROCENT_ASG_RUN is 0
default for POPRIRE_RATE_1_ASG_RUN is 0
default for POPRIRE_PLATITA_1_ASG_MONTH is 0

default for RATA is 0

default for ELEMENT_NAME is ' '


default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2000' (date)
default for POPRIRE_RATE_1_IAN_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_FEB_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_MAR_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_APR_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_MAI_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_IUN_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_IUL_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_AUG_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_SEP_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_OCT_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_NOI_ENTRY_VALUE is 0
default for POPRIRE_RATE_1_DEC_ENTRY_VALUE is 0

inputs are RATA

v_disponibil = REST_PLATA_2_ASG_MONTH

/* -----------------
Rata
----------------- */
v_rata = RATA
if RATA was defaulted then
( /* N 1 */
v_rata = POPRIRE_RATE_1_ASG_RUN

v_rata = round(v_rata * POPRIRE_RATE_LUNA_PROCENT_ASG_RUN / 100)


) /* N 1 */
/* -----------------
End: Rata
----------------- */

v_neacoperit_initial = POPRIRE_NEACOPERIT_1_ASG_ITD
v_rest_plata = POPRIRE_1_ASG_ITD

v_rata_de_platit = least(v_rata - POPRIRE_PLATITA_1_ASG_MONTH + v_neacoperit_initial,v_rest_plata)

v_rata_retinuta = least(v_disponibil,v_rata_de_platit)

v_neacoperit_final = v_rata_de_platit - v_rata_retinuta


if (v_neacoperit_final > 0) then
v_mesaj_1 = 'Atentie: ' + ELEMENT_NAME +
' : Retinere neacoperita = ' + to_text(v_neacoperit_final)

v_rest_plata = v_rest_plata - v_rata_retinuta

v_av = POPRIRE_PLATITA_1_ASG_MONTH
if (v_rest_plata > 0) then

return v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta,
v_rest_plata,
v_av

else
(
v_stop = 'S-a incheiat de platit poprirea'

return v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta,
v_rest_plata,
v_stop,
v_av
)

/* End: Formula: POPRIRE_RETINERE_1 */

POPRIRE_RETINERE_2

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: POPRIRE_RETINERE_2 */

default for REST_PLATA_2_ASG_MONTH is 0

default for POPRIRE_2_ASG_ITD is 0


default for POPRIRE_NEACOPERIT_2_ASG_ITD is 0
default for POPRIRE_RATE_LUNA_PROCENT_ASG_RUN is 0
default for POPRIRE_RATE_2_ASG_RUN is 0

default for RATA is 0

default for ELEMENT_NAME is ' '


default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2000' (date)

inputs are RATA

v_disponibil = REST_PLATA_2_ASG_MONTH

/* -----------------
Rata
----------------- */
v_rata = RATA
if RATA was defaulted then
( /* N 1 */
v_rata = POPRIRE_RATE_2_ASG_RUN

v_rata = round(v_rata * POPRIRE_RATE_LUNA_PROCENT_ASG_RUN / 100)


) /* N 1 */
/* -----------------
End: Rata
----------------- */

v_neacoperit_initial = POPRIRE_NEACOPERIT_2_ASG_ITD
v_rest_plata = POPRIRE_2_ASG_ITD

v_rata_de_platit = least(v_rata + v_neacoperit_initial,v_rest_plata)

v_rata_retinuta = least(v_disponibil,v_rata_de_platit)

v_neacoperit_final = v_rata_de_platit - v_rata_retinuta


if (v_neacoperit_final > 0) then
v_mesaj_1 = 'Atentie: ' + ELEMENT_NAME +
' : Retinere neacoperita = ' + to_text(v_neacoperit_final)

v_rest_plata = v_rest_plata - v_rata_retinuta

if (v_rest_plata > 0) then

return v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta,
v_rest_plata

else
(
v_stop = 'S-a incheiat de platit poprirea'

return v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta,
v_rest_plata,
v_stop
)

/* End: Formula: POPRIRE_RETINERE_2 */

POPRIRI

/* *******************************************************************

* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: POPRIRI */

default for POPRIRI_ASG_MONTH is 0

v_popriri = POPRIRI_ASG_MONTH

if (v_popriri <> 0) then v_suma = v_popriri

return v_popriri,

/* Conta popriri */

v_suma

/* End: Formula: POPRIRI */

PREAVIZ

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREAVIZ */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
default for FEL is ' ' /* cod = xx */
default for PERIOADA is 0
default for ORE_LIBERE is 0

default for PREAVIZ_DESFACERE_CONTRACT is 0


default for PREAVIZ_DEMISIE_FUNCTIE_EXECUTIE is 0
default for PREAVIZ_DEMISIE_FUNCTIE_CONDUCERE is 0
default for PREAVIZ_ORE_LIBERE is 0
default for DURATA_NORMALA_TIMP_LUCRU is 8
default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)
/* calcul luna */
default for PROCESARE_2_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
FEL,
PERIOADA,
ORE_LIBERE

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/* ---------------------------------------------------------------------------------------
Total zile
--------------------------------------------------------------------------------------- */
v_zile_drept = PERIOADA
if (PERIOADA was defaulted) then
(
if (FEL = '10') then v_zile_drept = PREAVIZ_DEMISIE_FUNCTIE_EXECUTIE
/* netratat
if (FEL = '10') then v_zile_drept = PREAVIZ_DEMISIE_FUNCTIE_CONDUCERE
*/
if (FEL = '20') then v_zile_drept = PREAVIZ_DESFACERE_CONTRACT
)
v_zile_t = GET_WORKING_DAYS(DATA_INCEPUT, DATA_SFARSIT)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = DATA_INCEPUT /* data inceput */
v_d_s = DATA_SFARSIT /* data sfarsit */
v_z = v_zile_t /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_t = v_z

if (v_zile_t <> v_zile_drept) then


(
v_m1 = 'Eroare ' + ELEMENT_NAME +
' Zile calculate ' + to_text(v_zile_t ) +
' # ' + ' Zile drept ' + to_text(v_zile_drept)
return v_m1
)
/* ---------------------------------------------------------------------------------------
End: Total zile
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
luna
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, DATA_SFARSIT )

v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile = v_z

v_ore_libere = ORE_LIBERE
if (ORE_LIBERE was defaulted) then v_ore_libere = PREAVIZ_ORE_LIBERE
v_ore = v_zile * v_ore_libere
/* ---------------------------------------------------------------------------------------
End: luna
--------------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
chenzina I
--------------------------------------------------------------------------------------- */
If (V_PLATA = 'C') then
( /* N 1 */
/* (1-15 ale lunii) */
v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)

v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)


v_data_sfarsit = least(v_d_15, DATA_SFARSIT)
v_zile_chenzina_I = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_chenzina_I = v_z

v_ore_chenzina_I = v_zile_chenzina_I * v_ore_libere


) /* N 1 */
/* ---------------------------------------------------------------------------------------
End: chenzina I
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Indemnizatie
--------------------------------------------------------------------------------------- */
/* calcul luna */
if (PROCESARE_2_ASG_RUN = 1) then v_indemn_ore = v_ore
/* ---------------------------------------------------------------------------------------
End: Indemnizatie
--------------------------------------------------------------------------------------- */

/* stop
--------*/
if (DATA_SFARSIT <= PAY_PROC_PERIOD_END_DATE) then
v_stop = ELEMENT_NAME + ' Stop '

return
v_stop,

/* comune */
DATA_INCEPUT,
DATA_SFARSIT,
FEL,
PERIOADA,
ORE_LIBERE,

/* Luna */
v_zile,
v_ore,

/* chenzina I */
v_zile_chenzina_I ,
v_ore_chenzina_I,

/* Indemnizatie */
v_indemn_ore

/* End: Formula: PREAVIZ */

PREAVIZ_INDEMNIZATIE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREAVIZ_INDEMNIZATIE */

default for ORE is 0

default for SALARIU_BAZA_ORAR_ASG_RUN is 0


default for SPORURI_NEGOCIATE_PROCENTE_ASG_RUN is 0
inputs are ORE

v_indemn = round( (SALARIU_BAZA_ORAR_ASG_RUN *


(1 + SPORURI_NEGOCIATE_PROCENTE_ASG_RUN / 100) ) *
(ORE) )

return
v_indemn

/* End: Formula: PREAVIZ_INDEMNIZATIE */

PREZENTA_CHENZINA_I

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREZENTA_CHENZINA_I */

/*
[TN]=CM, CO, EV, CP, FP, AN, P, D, R, SC, L, RC
EV=Evenimente Familiale, CP=Concediu Cu Plata, FP=Concediu Fara Plata,
AN=Absenta Nemotivata, P=Preaviz
D=Delegatie, R=Recuperare, SC= Suspendare Contract, L=Liber, RC=Rechemare CO
*/

default for ORE_LUCRATE_CHENZINA_I_ASG_RUN is 0


default for ORE_CM_CHENZINA_I_ASG_RUN is 0
default for ORE_CO_CHENZINA_I_ASG_RUN is 0
default for ORE_EV_CHENZINA_I_ASG_RUN is 0
default for ORE_CCP_CHENZINA_I_ASG_RUN is 0
default for ORE_CFP_CHENZINA_I_ASG_RUN is 0
default for ORE_AN_CHENZINA_I_ASG_RUN is 0
default for ORE_PREAVIZ_CHENZINA_I_ASG_RUN is 0
default for ORE_SC_CHENZINA_I_ASG_RUN is 0
default for ORE_DELEGATIE_CHENZINA_I_ASG_RUN is 0
default for ORE_RECUPERARE_CHENZINA_I_ASG_RUN is 0

/* ---------------------------------------------------------------------------------------
Total Ore
--------------------------------------------------------------------------------------- */
v_Lucrat_chenzina_I = ORE_LUCRATE_CHENZINA_I_ASG_RUN

v_CM_chenzina_I = ORE_CM_CHENZINA_I_ASG_RUN
v_CO_chenzina_I = ORE_CO_CHENZINA_I_ASG_RUN
v_EV_chenzina_I = ORE_EV_CHENZINA_I_ASG_RUN
v_CP_chenzina_I = ORE_CCP_CHENZINA_I_ASG_RUN
v_FP_chenzina_I = ORE_CFP_CHENZINA_I_ASG_RUN
v_P_chenzina_I = ORE_PREAVIZ_CHENZINA_I_ASG_RUN
v_AN_chenzina_I = ORE_AN_CHENZINA_I_ASG_RUN
v_SC_chenzina_I = ORE_SC_CHENZINA_I_ASG_RUN
v_D_chenzina_I = ORE_DELEGATIE_CHENZINA_I_ASG_RUN
v_R_chenzina_I = ORE_RECUPERARE_CHENZINA_I_ASG_RUN
/*
v_L_chenzina_I =
v_RC_chenzina_I =
*/
/* ---------------------------------------------------------------------------------------
End: Total Ore
--------------------------------------------------------------------------------------- */

return
v_Lucrat_chenzina_I,
v_CM_chenzina_I,
v_CO_chenzina_I,
v_EV_chenzina_I,
v_CP_chenzina_I,
v_FP_chenzina_I,
v_P_chenzina_I,
v_AN_chenzina_I,
v_D_chenzina_I,
v_R_chenzina_I,
v_SC_chenzina_I
/*
v_L_chenzina_I,
v_RC_chenzina_I
*/

/* End: Formula: PREZENTA_CHENZINA_I */

PREZENTA_LUNA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREZENTA_LUNA */

/*
[TN]=CM, CO, EV, CP, FP, AN, P, D, R, SC, L, RC
EV=Evenimente Familiale, CP=Concediu Cu Plata, FP=Concediu Fara Plata,
AN=Absenta Nemotivata, P=Preaviz
D=Delegatie, R=Recuperare, SC= Suspendare Contract, L=Liber, RC=Rechemare CO
SD= SD Timp suplimentar
*/

default for ORE_LUCRATE_LUNA_ASG_RUN is 0


default for ORE_CM_LUNA_ASG_RUN is 0
default for ORE_CO_LUNA_ASG_RUN is 0
default for ORE_EV_LUNA_ASG_RUN is 0
default for ORE_CCP_LUNA_ASG_RUN is 0
default for ORE_CFP_LUNA_ASG_RUN is 0
default for ORE_AN_LUNA_ASG_RUN is 0
default for ORE_PREAVIZ_LUNA_ASG_RUN is 0
default for ORE_SC_LUNA_ASG_RUN is 0
default for ORE_DELEGATIE_LUNA_ASG_RUN is 0
default for ORE_RECUPERARE_LUNA_ASG_RUN is 0
default for ORE_TS_LUNA_ASG_RUN is 0 /* lmmjv + sd + sarbatori */
default for ORE_LIBER_LUNA_ASG_RUN is 0

/* ---------------------------------------------------------------------------------------
Total Ore
--------------------------------------------------------------------------------------- */
v_Lucrat_luna = ORE_LUCRATE_LUNA_ASG_RUN

v_CM_luna = ORE_CM_LUNA_ASG_RUN
v_CO_luna = ORE_CO_LUNA_ASG_RUN
v_EV_luna = ORE_EV_LUNA_ASG_RUN
v_CP_luna = ORE_CCP_LUNA_ASG_RUN
v_FP_luna = ORE_CFP_LUNA_ASG_RUN
v_P_luna = ORE_PREAVIZ_LUNA_ASG_RUN
v_AN_luna = ORE_AN_LUNA_ASG_RUN
v_SC_luna = ORE_SC_LUNA_ASG_RUN
v_D_luna = ORE_DELEGATIE_LUNA_ASG_RUN
v_R_luna = ORE_RECUPERARE_LUNA_ASG_RUN
v_SD_luna = ORE_TS_LUNA_ASG_RUN
v_L_luna = ORE_LIBER_LUNA_ASG_RUN
/*
v_RC_luna =
*/

/* ---------------------------------------------------------------------------------------
End: Total Ore
--------------------------------------------------------------------------------------- */

return
v_Lucrat_luna,
v_CM_luna,
v_CO_luna,
v_EV_luna,
v_CP_luna,
v_FP_luna,
v_P_luna,
v_AN_luna,
v_D_luna,
v_R_luna,
v_SC_luna,
v_SD_luna,
v_L_luna
/*
v_RC_luna
*/

/* End: Formula: PREZENTA_LUNA */


PREZENTA_SAPTAMANA_1

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREZENTA_SAPTAMANA_1 */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* Liber zi [nr] din Grafic luna corectii */


default for LIBER_ZI_1_ASG_RUN is 0
default for LIBER_ZI_2_ASG_RUN is 0
default for LIBER_ZI_3_ASG_RUN is 0
default for LIBER_ZI_4_ASG_RUN is 0
default for LIBER_ZI_5_ASG_RUN is 0
default for LIBER_ZI_6_ASG_RUN is 0
default for LIBER_ZI_7_ASG_RUN is 0

/* [TN] zi [nr]*/
default for CP_ZI_1_ASG_RUN is 0
default for CP_ZI_2_ASG_RUN is 0
default for CP_ZI_3_ASG_RUN is 0
default for CP_ZI_4_ASG_RUN is 0
default for CP_ZI_5_ASG_RUN is 0
default for CP_ZI_6_ASG_RUN is 0
default for CP_ZI_7_ASG_RUN is 0

default for FP_ZI_1_ASG_RUN is 0


default for FP_ZI_2_ASG_RUN is 0
default for FP_ZI_3_ASG_RUN is 0
default for FP_ZI_4_ASG_RUN is 0
default for FP_ZI_5_ASG_RUN is 0
default for FP_ZI_6_ASG_RUN is 0
default for FP_ZI_7_ASG_RUN is 0

default for EV_ZI_1_ASG_RUN is 0


default for EV_ZI_2_ASG_RUN is 0
default for EV_ZI_3_ASG_RUN is 0
default for EV_ZI_4_ASG_RUN is 0
default for EV_ZI_5_ASG_RUN is 0
default for EV_ZI_6_ASG_RUN is 0
default for EV_ZI_7_ASG_RUN is 0

default for CO_ZI_1_ASG_RUN is 0


default for CO_ZI_2_ASG_RUN is 0
default for CO_ZI_3_ASG_RUN is 0
default for CO_ZI_4_ASG_RUN is 0
default for CO_ZI_5_ASG_RUN is 0
default for CO_ZI_6_ASG_RUN is 0
default for CO_ZI_7_ASG_RUN is 0

default for CM_ZI_1_ASG_RUN is 0


default for CM_ZI_2_ASG_RUN is 0
default for CM_ZI_3_ASG_RUN is 0
default for CM_ZI_4_ASG_RUN is 0
default for CM_ZI_5_ASG_RUN is 0
default for CM_ZI_6_ASG_RUN is 0
default for CM_ZI_7_ASG_RUN is 0

default for P_ZI_1_ASG_RUN is 0


default for P_ZI_2_ASG_RUN is 0
default for P_ZI_3_ASG_RUN is 0
default for P_ZI_4_ASG_RUN is 0
default for P_ZI_5_ASG_RUN is 0
default for P_ZI_6_ASG_RUN is 0
default for P_ZI_7_ASG_RUN is 0

default for AN_ZI_1_ASG_RUN is 0


default for AN_ZI_2_ASG_RUN is 0
default for AN_ZI_3_ASG_RUN is 0
default for AN_ZI_4_ASG_RUN is 0
default for AN_ZI_5_ASG_RUN is 0
default for AN_ZI_6_ASG_RUN is 0
default for AN_ZI_7_ASG_RUN is 0

default for SC_ZI_1_ASG_RUN is 0


default for SC_ZI_2_ASG_RUN is 0
default for SC_ZI_3_ASG_RUN is 0
default for SC_ZI_4_ASG_RUN is 0
default for SC_ZI_5_ASG_RUN is 0
default for SC_ZI_6_ASG_RUN is 0
default for SC_ZI_7_ASG_RUN is 0

/* TN Zi [nr] */
default for TN_ZI_1_ASG_RUN is 0
default for TN_ZI_2_ASG_RUN is 0
default for TN_ZI_3_ASG_RUN is 0
default for TN_ZI_4_ASG_RUN is 0
default for TN_ZI_5_ASG_RUN is 0
default for TN_ZI_6_ASG_RUN is 0
default for TN_ZI_7_ASG_RUN is 0

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_nr_ore = v_durata_muncii
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* zi 1 */
if (v_nr_ore < TN_ZI_1_ASG_RUN) or (TN_ZI_1_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 1 TN = ' + to_text(TN_ZI_1_ASG_RUN)
return v_m1)
/* zi 2 */
if (v_nr_ore < TN_ZI_2_ASG_RUN) or (TN_ZI_2_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 2 TN = ' + to_text(TN_ZI_2_ASG_RUN)
return v_m1)
/* zi 3 */
if (v_nr_ore < TN_ZI_3_ASG_RUN) or (TN_ZI_3_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 3 TN = ' + to_text(TN_ZI_3_ASG_RUN)
return v_m1)
/* zi 4 */
if (v_nr_ore < TN_ZI_4_ASG_RUN) or (TN_ZI_4_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 4 TN = ' + to_text(TN_ZI_4_ASG_RUN)
return v_m1)
/* zi 5 */
if (v_nr_ore < TN_ZI_5_ASG_RUN) or (TN_ZI_5_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 5 TN = ' + to_text(TN_ZI_5_ASG_RUN)
return v_m1)
/* zi 6 */
if (v_nr_ore < TN_ZI_6_ASG_RUN) or (TN_ZI_6_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 6 TN = ' + to_text(TN_ZI_6_ASG_RUN)
return v_m1)
/* zi 7 */
if (v_nr_ore < TN_ZI_7_ASG_RUN) or (TN_ZI_7_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 7 TN = ' + to_text(TN_ZI_7_ASG_RUN)
return v_m1)
/* ---------------------------------------------------------------------------------------
End: Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Prezenta
--------------------------------------------------------------------------------------- */
/* zi 1
------------------------------------------------------------------------*/
v_zi = PAY_PROC_PERIOD_START_DATE
v_p_1 = ' '

/* este in luna curenta */


if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_1 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_1_ASG_RUN > 0) then
if (LIBER_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = ' '
else v_p_1 = to_text(v_nr_ore - LIBER_ZI_1_ASG_RUN)
if (CP_ZI_1_ASG_RUN > 0) then
if (CP_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'CP'
else v_p_1 = to_text(v_nr_ore - CP_ZI_1_ASG_RUN)
if (FP_ZI_1_ASG_RUN > 0) then
if (FP_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'FP'
else v_p_1 = to_text(v_nr_ore - FP_ZI_1_ASG_RUN)
if (EV_ZI_1_ASG_RUN > 0) then
if (EV_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'EV'
else v_p_1 = to_text(v_nr_ore - EV_ZI_1_ASG_RUN)
if (CO_ZI_1_ASG_RUN > 0) then
if (CO_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'CO'
else v_p_1 = to_text(v_nr_ore - CO_ZI_1_ASG_RUN)
if (CM_ZI_1_ASG_RUN > 0) then
if (CM_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'CM'
else v_p_1 = to_text(v_nr_ore - CM_ZI_1_ASG_RUN)
if (P_ZI_1_ASG_RUN > 0) then
if (P_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'P'
else v_p_1 = to_text(v_nr_ore - P_ZI_1_ASG_RUN)
if (AN_ZI_1_ASG_RUN > 0) then
if (AN_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'AN'
else v_p_1 = to_text(v_nr_ore - AN_ZI_1_ASG_RUN)
if (SC_ZI_1_ASG_RUN > 0) then
if (SC_ZI_1_ASG_RUN = v_nr_ore)
then v_p_1 = 'SC'
else v_p_1 = to_text(v_nr_ore - SC_ZI_1_ASG_RUN)
)

/* zi 2
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_2 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_2 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_2_ASG_RUN > 0) then
if (LIBER_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = ' '
else v_p_2 = to_text(v_nr_ore - LIBER_ZI_1_ASG_RUN)
if (CP_ZI_2_ASG_RUN > 0) then
if (CP_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'CP'
else v_p_2 = to_text(v_nr_ore - CP_ZI_2_ASG_RUN)
if (FP_ZI_2_ASG_RUN > 0) then
if (FP_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'FP'
else v_p_2 = to_text(v_nr_ore - FP_ZI_2_ASG_RUN)
if (EV_ZI_2_ASG_RUN > 0) then
if (EV_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'EV'
else v_p_2 = to_text(v_nr_ore - EV_ZI_2_ASG_RUN)
if (CO_ZI_2_ASG_RUN > 0) then
if (CO_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'CO'
else v_p_2 = to_text(v_nr_ore - CO_ZI_2_ASG_RUN)
if (CM_ZI_2_ASG_RUN > 0) then
if (CM_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'CM'
else v_p_2 = to_text(v_nr_ore - CM_ZI_2_ASG_RUN)
if (P_ZI_2_ASG_RUN > 0) then
if (P_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'P'
else v_p_2 = to_text(v_nr_ore - P_ZI_2_ASG_RUN)
if (SC_ZI_2_ASG_RUN > 0) then
if (SC_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'SC'
else v_p_2 = to_text(v_nr_ore - SC_ZI_2_ASG_RUN)
if (AN_ZI_2_ASG_RUN > 0) then
if (AN_ZI_2_ASG_RUN = v_nr_ore)
then v_p_2 = 'AN'
else v_p_2 = to_text(v_nr_ore - AN_ZI_2_ASG_RUN)
)

/* zi 3
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_3 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_3 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_3_ASG_RUN > 0) then
if (LIBER_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = ' '
else v_p_3 = to_text(v_nr_ore - LIBER_ZI_3_ASG_RUN)
if (CP_ZI_3_ASG_RUN > 0) then
if (CP_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'CP'
else v_p_3 = to_text(v_nr_ore - CP_ZI_3_ASG_RUN)
if (FP_ZI_3_ASG_RUN > 0) then
if (FP_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'FP'
else v_p_3 = to_text(v_nr_ore - FP_ZI_3_ASG_RUN)
if (EV_ZI_3_ASG_RUN > 0) then
if (EV_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'EV'
else v_p_3 = to_text(v_nr_ore - EV_ZI_3_ASG_RUN)
if (CO_ZI_3_ASG_RUN > 0) then
if (CO_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'CO'
else v_p_3 = to_text(v_nr_ore - CO_ZI_3_ASG_RUN)
if (CM_ZI_3_ASG_RUN > 0) then
if (CM_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'CM'
else v_p_3 = to_text(v_nr_ore - CM_ZI_3_ASG_RUN)
if (P_ZI_3_ASG_RUN > 0) then
if (P_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'P'
else v_p_3 = to_text(v_nr_ore - P_ZI_3_ASG_RUN)
if (AN_ZI_3_ASG_RUN > 0) then
if (AN_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'AN'
else v_p_3 = to_text(v_nr_ore - AN_ZI_3_ASG_RUN)
if (SC_ZI_3_ASG_RUN > 0) then
if (SC_ZI_3_ASG_RUN = v_nr_ore)
then v_p_3 = 'SC'
else v_p_3 = to_text(v_nr_ore - SC_ZI_3_ASG_RUN)
)

/* zi 4
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_4 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_4 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_4_ASG_RUN > 0) then
if (LIBER_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = ' '
else v_p_4 = to_text(v_nr_ore - LIBER_ZI_4_ASG_RUN)
if (CP_ZI_4_ASG_RUN > 0) then
if (CP_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'CP'
else v_p_4 = to_text(v_nr_ore - CP_ZI_4_ASG_RUN)
if (FP_ZI_4_ASG_RUN > 0) then
if (FP_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'FP'
else v_p_4 = to_text(v_nr_ore - FP_ZI_4_ASG_RUN)
if (EV_ZI_4_ASG_RUN > 0) then
if (EV_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'EV'
else v_p_4 = to_text(v_nr_ore - EV_ZI_4_ASG_RUN)
if (CO_ZI_4_ASG_RUN > 0) then
if (CO_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'CO'
else v_p_4 = to_text(v_nr_ore - CO_ZI_4_ASG_RUN)
if (CM_ZI_4_ASG_RUN > 0) then
if (CM_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'CM'
else v_p_4 = to_text(v_nr_ore - CM_ZI_4_ASG_RUN)
if (P_ZI_4_ASG_RUN > 0) then
if (P_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'P'
else v_p_4 = to_text(v_nr_ore - P_ZI_4_ASG_RUN)
if (SC_ZI_4_ASG_RUN > 0) then
if (SC_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'SC'
else v_p_4 = to_text(v_nr_ore - SC_ZI_4_ASG_RUN)
if (AN_ZI_4_ASG_RUN > 0) then
if (AN_ZI_4_ASG_RUN = v_nr_ore)
then v_p_4 = 'AN'
else v_p_4 = to_text(v_nr_ore - AN_ZI_4_ASG_RUN)
)

/* zi 5
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_5 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_5 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_5_ASG_RUN > 0) then
if (LIBER_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = ' '
else v_p_5 = to_text(v_nr_ore - LIBER_ZI_5_ASG_RUN)
if (CP_ZI_5_ASG_RUN > 0) then
if (CP_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'CP'
else v_p_5 = to_text(v_nr_ore - CP_ZI_5_ASG_RUN)
if (FP_ZI_5_ASG_RUN > 0) then
if (FP_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'FP'
else v_p_5 = to_text(v_nr_ore - FP_ZI_5_ASG_RUN)
if (EV_ZI_5_ASG_RUN > 0) then
if (EV_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'EV'
else v_p_5 = to_text(v_nr_ore - EV_ZI_5_ASG_RUN)
if (CO_ZI_5_ASG_RUN > 0) then
if (CO_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'CO'
else v_p_5 = to_text(v_nr_ore - CO_ZI_5_ASG_RUN)
if (CM_ZI_5_ASG_RUN > 0) then
if (CM_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'CM'
else v_p_5 = to_text(v_nr_ore - CM_ZI_5_ASG_RUN)
if (P_ZI_5_ASG_RUN > 0) then
if (P_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'P'
else v_p_5 = to_text(v_nr_ore - P_ZI_5_ASG_RUN)
if (AN_ZI_5_ASG_RUN > 0) then
if (AN_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'AN'
else v_p_5 = to_text(v_nr_ore - AN_ZI_5_ASG_RUN)
if (SC_ZI_5_ASG_RUN > 0) then
if (SC_ZI_5_ASG_RUN = v_nr_ore)
then v_p_5 = 'SC'
else v_p_5 = to_text(v_nr_ore - SC_ZI_5_ASG_RUN)
)
/* zi 6
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_6 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_6 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_6_ASG_RUN > 0) then
if (LIBER_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = ' '
else v_p_6 = to_text(v_nr_ore - LIBER_ZI_6_ASG_RUN)
if (CP_ZI_6_ASG_RUN > 0) then
if (CP_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'CP'
else v_p_6 = to_text(v_nr_ore - CP_ZI_6_ASG_RUN)
if (FP_ZI_6_ASG_RUN > 0) then
if (FP_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'FP'
else v_p_6 = to_text(v_nr_ore - FP_ZI_6_ASG_RUN)
if (EV_ZI_6_ASG_RUN > 0) then
if (EV_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'EV'
else v_p_6 = to_text(v_nr_ore - EV_ZI_6_ASG_RUN)
if (CO_ZI_6_ASG_RUN > 0) then
if (CO_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'CO'
else v_p_6 = to_text(v_nr_ore - CO_ZI_6_ASG_RUN)
if (CM_ZI_6_ASG_RUN > 0) then
if (CM_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'CM'
else v_p_6 = to_text(v_nr_ore - CM_ZI_6_ASG_RUN)
if (P_ZI_6_ASG_RUN > 0) then
if (P_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'P'
else v_p_6 = to_text(v_nr_ore - P_ZI_6_ASG_RUN)
if (SC_ZI_6_ASG_RUN > 0) then
if (SC_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'SC'
else v_p_6 = to_text(v_nr_ore - SC_ZI_6_ASG_RUN)
if (AN_ZI_6_ASG_RUN > 0) then
if (AN_ZI_6_ASG_RUN = v_nr_ore)
then v_p_6 = 'AN'
else v_p_6 = to_text(v_nr_ore - AN_ZI_6_ASG_RUN)
)

/* zi 7
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_7 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_7 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_7_ASG_RUN > 0) then
if (LIBER_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = ' '
else v_p_7 = to_text(v_nr_ore - LIBER_ZI_7_ASG_RUN)
if (CP_ZI_7_ASG_RUN > 0) then
if (CP_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'CP'
else v_p_7 = to_text(v_nr_ore - CP_ZI_7_ASG_RUN)
if (FP_ZI_7_ASG_RUN > 0) then
if (FP_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'FP'
else v_p_7 = to_text(v_nr_ore - FP_ZI_7_ASG_RUN)
if (EV_ZI_7_ASG_RUN > 0) then
if (EV_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'EV'
else v_p_7 = to_text(v_nr_ore - EV_ZI_7_ASG_RUN)
if (CO_ZI_7_ASG_RUN > 0) then
if (CO_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'CO'
else v_p_7 = to_text(v_nr_ore - CO_ZI_7_ASG_RUN)
if (CM_ZI_7_ASG_RUN > 0) then
if (CM_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'CM'
else v_p_7 = to_text(v_nr_ore - CM_ZI_7_ASG_RUN)
if (P_ZI_7_ASG_RUN > 0) then
if (P_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'P'
else v_p_7 = to_text(v_nr_ore - P_ZI_7_ASG_RUN)
if (AN_ZI_7_ASG_RUN > 0) then
if (AN_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'AN'
else v_p_7 = to_text(v_nr_ore - AN_ZI_7_ASG_RUN)
if (SC_ZI_7_ASG_RUN > 0) then
if (SC_ZI_7_ASG_RUN = v_nr_ore)
then v_p_7 = 'SC'
else v_p_7 = to_text(v_nr_ore - SC_ZI_7_ASG_RUN)
)
/* ---------------------------------------------------------------------------------------
End: Prezenta
--------------------------------------------------------------------------------------- */

return
/* Prezenta */
v_p_1,
v_p_2,
v_p_3,
v_p_4,
v_p_5,
v_p_6,
v_p_7

/* End: Formula: PREZENTA_SAPTAMANA_1 */


PREZENTA_SAPTAMANA_2

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREZENTA_SAPTAMANA_2 */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* Liber zi [nr] din Grafic luna corectii */


default for LIBER_ZI_8_ASG_RUN is 0
default for LIBER_ZI_9_ASG_RUN is 0
default for LIBER_ZI_10_ASG_RUN is 0
default for LIBER_ZI_11_ASG_RUN is 0
default for LIBER_ZI_12_ASG_RUN is 0
default for LIBER_ZI_13_ASG_RUN is 0
default for LIBER_ZI_14_ASG_RUN is 0

/* [TN] zi [nr]*/
default for CP_ZI_8_ASG_RUN is 0
default for CP_ZI_9_ASG_RUN is 0
default for CP_ZI_10_ASG_RUN is 0
default for CP_ZI_11_ASG_RUN is 0
default for CP_ZI_12_ASG_RUN is 0
default for CP_ZI_13_ASG_RUN is 0
default for CP_ZI_14_ASG_RUN is 0

default for FP_ZI_8_ASG_RUN is 0


default for FP_ZI_9_ASG_RUN is 0
default for FP_ZI_10_ASG_RUN is 0
default for FP_ZI_11_ASG_RUN is 0
default for FP_ZI_12_ASG_RUN is 0
default for FP_ZI_13_ASG_RUN is 0
default for FP_ZI_14_ASG_RUN is 0
default for EV_ZI_8_ASG_RUN is 0
default for EV_ZI_9_ASG_RUN is 0
default for EV_ZI_10_ASG_RUN is 0
default for EV_ZI_11_ASG_RUN is 0
default for EV_ZI_12_ASG_RUN is 0
default for EV_ZI_13_ASG_RUN is 0
default for EV_ZI_14_ASG_RUN is 0

default for CO_ZI_8_ASG_RUN is 0


default for CO_ZI_9_ASG_RUN is 0
default for CO_ZI_10_ASG_RUN is 0
default for CO_ZI_11_ASG_RUN is 0
default for CO_ZI_12_ASG_RUN is 0
default for CO_ZI_13_ASG_RUN is 0
default for CO_ZI_14_ASG_RUN is 0

default for CM_ZI_8_ASG_RUN is 0


default for CM_ZI_9_ASG_RUN is 0
default for CM_ZI_10_ASG_RUN is 0
default for CM_ZI_11_ASG_RUN is 0
default for CM_ZI_12_ASG_RUN is 0
default for CM_ZI_13_ASG_RUN is 0
default for CM_ZI_14_ASG_RUN is 0

default for P_ZI_8_ASG_RUN is 0


default for P_ZI_9_ASG_RUN is 0
default for P_ZI_10_ASG_RUN is 0
default for P_ZI_11_ASG_RUN is 0
default for P_ZI_12_ASG_RUN is 0
default for P_ZI_13_ASG_RUN is 0
default for P_ZI_14_ASG_RUN is 0

default for AN_ZI_8_ASG_RUN is 0


default for AN_ZI_9_ASG_RUN is 0
default for AN_ZI_10_ASG_RUN is 0
default for AN_ZI_11_ASG_RUN is 0
default for AN_ZI_12_ASG_RUN is 0
default for AN_ZI_13_ASG_RUN is 0
default for AN_ZI_14_ASG_RUN is 0

default for SC_ZI_8_ASG_RUN is 0


default for SC_ZI_9_ASG_RUN is 0
default for SC_ZI_10_ASG_RUN is 0
default for SC_ZI_11_ASG_RUN is 0
default for SC_ZI_12_ASG_RUN is 0
default for SC_ZI_13_ASG_RUN is 0
default for SC_ZI_14_ASG_RUN is 0

/* TN Zi [nr] */
default for TN_ZI_8_ASG_RUN is 0
default for TN_ZI_9_ASG_RUN is 0
default for TN_ZI_10_ASG_RUN is 0
default for TN_ZI_11_ASG_RUN is 0
default for TN_ZI_12_ASG_RUN is 0
default for TN_ZI_13_ASG_RUN is 0
default for TN_ZI_14_ASG_RUN is 0

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_nr_ore = v_durata_muncii
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* zi 8 */
if (v_nr_ore < TN_ZI_8_ASG_RUN) or (TN_ZI_8_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 8 TN = ' + to_text(TN_ZI_8_ASG_RUN)
return v_m1)
/* zi 9 */
if (v_nr_ore < TN_ZI_9_ASG_RUN) or (TN_ZI_9_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 9 TN = ' + to_text(TN_ZI_9_ASG_RUN)
return v_m1)
/* zi 10 */
if (v_nr_ore < TN_ZI_10_ASG_RUN) or (TN_ZI_10_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 10 TN = ' + to_text(TN_ZI_10_ASG_RUN)
return v_m1)
/* zi 11 */
if (v_nr_ore < TN_ZI_11_ASG_RUN) or (TN_ZI_11_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 11 TN = ' + to_text(TN_ZI_11_ASG_RUN)
return v_m1)
/* zi 12 */
if (v_nr_ore < TN_ZI_12_ASG_RUN) or (TN_ZI_12_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 12 TN = ' + to_text(TN_ZI_12_ASG_RUN)
return v_m1)
/* zi 13 */
if (v_nr_ore < TN_ZI_13_ASG_RUN) or (TN_ZI_13_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 13 TN = ' + to_text(TN_ZI_13_ASG_RUN)
return v_m1)
/* zi 14 */
if (v_nr_ore < TN_ZI_14_ASG_RUN) or (TN_ZI_14_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 14 TN = ' + to_text(TN_ZI_14_ASG_RUN)
return v_m1)
/* ---------------------------------------------------------------------------------------
End: Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Prezenta
--------------------------------------------------------------------------------------- */
/* zi 8
------------------------------------------------------------------------*/
v_zi = to_date('08-' + to_text(PAY_PROC_PERIOD_START_DATE, 'MON') + '-' +
to_text(PAY_PROC_PERIOD_START_DATE, 'YYYY'))
v_p_8 = ' '

/* este in luna curenta */


if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_8 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_8_ASG_RUN > 0) then
if (LIBER_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = ' '
else v_p_8 = to_text(v_nr_ore - LIBER_ZI_8_ASG_RUN)
if (CP_ZI_8_ASG_RUN > 0) then
if (CP_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'CP'
else v_p_8 = to_text(v_nr_ore - CP_ZI_8_ASG_RUN)
if (FP_ZI_8_ASG_RUN > 0) then
if (FP_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'FP'
else v_p_8 = to_text(v_nr_ore - FP_ZI_8_ASG_RUN)
if (EV_ZI_8_ASG_RUN > 0) then
if (EV_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'EV'
else v_p_8 = to_text(v_nr_ore - EV_ZI_8_ASG_RUN)
if (CO_ZI_8_ASG_RUN > 0) then
if (CO_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'CO'
else v_p_8 = to_text(v_nr_ore - CO_ZI_8_ASG_RUN)
if (CM_ZI_8_ASG_RUN > 0) then
if (CM_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'CM'
else v_p_8 = to_text(v_nr_ore - CM_ZI_8_ASG_RUN)
if (P_ZI_8_ASG_RUN > 0) then
if (P_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'P'
else v_p_8 = to_text(v_nr_ore - P_ZI_8_ASG_RUN)
if (SC_ZI_8_ASG_RUN > 0) then
if (SC_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'SC'
else v_p_8 = to_text(v_nr_ore - SC_ZI_8_ASG_RUN)
if (AN_ZI_8_ASG_RUN > 0) then
if (AN_ZI_8_ASG_RUN = v_nr_ore)
then v_p_8 = 'AN'
else v_p_8 = to_text(v_nr_ore - AN_ZI_8_ASG_RUN)
)

/* zi 9
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_9 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_9 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_9_ASG_RUN > 0) then
if (LIBER_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = ' '
else v_p_9 = to_text(v_nr_ore - LIBER_ZI_9_ASG_RUN)
if (CP_ZI_9_ASG_RUN > 0) then
if (CP_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'CP'
else v_p_9 = to_text(v_nr_ore - CP_ZI_9_ASG_RUN)
if (FP_ZI_9_ASG_RUN > 0) then
if (FP_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'FP'
else v_p_9 = to_text(v_nr_ore - FP_ZI_9_ASG_RUN)
if (EV_ZI_9_ASG_RUN > 0) then
if (EV_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'EV'
else v_p_9 = to_text(v_nr_ore - EV_ZI_9_ASG_RUN)
if (CO_ZI_9_ASG_RUN > 0) then
if (CO_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'CO'
else v_p_9 = to_text(v_nr_ore - CO_ZI_9_ASG_RUN)
if (CM_ZI_9_ASG_RUN > 0) then
if (CM_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'CM'
else v_p_9 = to_text(v_nr_ore - CM_ZI_9_ASG_RUN)
if (P_ZI_9_ASG_RUN > 0) then
if (P_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'P'
else v_p_9 = to_text(v_nr_ore - P_ZI_9_ASG_RUN)
if (AN_ZI_9_ASG_RUN > 0) then
if (AN_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'AN'
else v_p_9 = to_text(v_nr_ore - AN_ZI_9_ASG_RUN)
if (SC_ZI_9_ASG_RUN > 0) then
if (SC_ZI_9_ASG_RUN = v_nr_ore)
then v_p_9 = 'SC'
else v_p_9 = to_text(v_nr_ore - SC_ZI_9_ASG_RUN)
)

/* zi 10
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_10 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_10 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_10_ASG_RUN > 0) then
if (LIBER_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = ' '
else v_p_10 = to_text(v_nr_ore - LIBER_ZI_10_ASG_RUN)
if (CP_ZI_10_ASG_RUN > 0) then
if (CP_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'CP'
else v_p_10 = to_text(v_nr_ore - CP_ZI_10_ASG_RUN)
if (FP_ZI_10_ASG_RUN > 0) then
if (FP_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'FP'
else v_p_10 = to_text(v_nr_ore - FP_ZI_10_ASG_RUN)
if (EV_ZI_10_ASG_RUN > 0) then
if (EV_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'EV'
else v_p_10 = to_text(v_nr_ore - EV_ZI_10_ASG_RUN)
if (CO_ZI_10_ASG_RUN > 0) then
if (CO_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'CO'
else v_p_10 = to_text(v_nr_ore - CO_ZI_10_ASG_RUN)
if (CM_ZI_10_ASG_RUN > 0) then
if (CM_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'CM'
else v_p_10 = to_text(v_nr_ore - CM_ZI_10_ASG_RUN)
if (P_ZI_10_ASG_RUN > 0) then
if (P_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'P'
else v_p_10 = to_text(v_nr_ore - P_ZI_10_ASG_RUN)
if (SC_ZI_10_ASG_RUN > 0) then
if (SC_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'SC'
else v_p_10 = to_text(v_nr_ore - SC_ZI_10_ASG_RUN)
if (AN_ZI_10_ASG_RUN > 0) then
if (AN_ZI_10_ASG_RUN = v_nr_ore)
then v_p_10 = 'AN'
else v_p_10 = to_text(v_nr_ore - AN_ZI_10_ASG_RUN)
)

/* zi 11
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_11 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_11 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_11_ASG_RUN > 0) then
if (LIBER_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = ' '
else v_p_11 = to_text(v_nr_ore - LIBER_ZI_11_ASG_RUN)
if (CP_ZI_11_ASG_RUN > 0) then
if (CP_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'CP'
else v_p_11 = to_text(v_nr_ore - CP_ZI_11_ASG_RUN)
if (FP_ZI_11_ASG_RUN > 0) then
if (FP_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'FP'
else v_p_11 = to_text(v_nr_ore - FP_ZI_11_ASG_RUN)
if (EV_ZI_11_ASG_RUN > 0) then
if (EV_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'EV'
else v_p_11 = to_text(v_nr_ore - EV_ZI_11_ASG_RUN)
if (CO_ZI_11_ASG_RUN > 0) then
if (CO_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'CO'
else v_p_11 = to_text(v_nr_ore - CO_ZI_11_ASG_RUN)
if (CM_ZI_11_ASG_RUN > 0) then
if (CM_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'CM'
else v_p_11 = to_text(v_nr_ore - CM_ZI_11_ASG_RUN)
if (P_ZI_11_ASG_RUN > 0) then
if (P_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'P'
else v_p_11 = to_text(v_nr_ore - P_ZI_11_ASG_RUN)
if (AN_ZI_11_ASG_RUN > 0) then
if (AN_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'AN'
else v_p_11 = to_text(v_nr_ore - AN_ZI_11_ASG_RUN)
if (SC_ZI_11_ASG_RUN > 0) then
if (SC_ZI_11_ASG_RUN = v_nr_ore)
then v_p_11 = 'SC'
else v_p_11 = to_text(v_nr_ore - SC_ZI_11_ASG_RUN)
)

/* zi 12
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_12 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_12 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_12_ASG_RUN > 0) then
if (LIBER_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = ' '
else v_p_12 = to_text(v_nr_ore - LIBER_ZI_12_ASG_RUN)
if (CP_ZI_12_ASG_RUN > 0) then
if (CP_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'CP'
else v_p_12 = to_text(v_nr_ore - CP_ZI_12_ASG_RUN)
if (FP_ZI_12_ASG_RUN > 0) then
if (FP_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'FP'
else v_p_12 = to_text(v_nr_ore - FP_ZI_12_ASG_RUN)
if (EV_ZI_12_ASG_RUN > 0) then
if (EV_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'EV'
else v_p_12 = to_text(v_nr_ore - EV_ZI_12_ASG_RUN)
if (CO_ZI_12_ASG_RUN > 0) then
if (CO_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'CO'
else v_p_12 = to_text(v_nr_ore - CO_ZI_12_ASG_RUN)
if (CM_ZI_12_ASG_RUN > 0) then
if (CM_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'CM'
else v_p_12 = to_text(v_nr_ore - CM_ZI_12_ASG_RUN)
if (P_ZI_12_ASG_RUN > 0) then
if (P_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'P'
else v_p_12 = to_text(v_nr_ore - P_ZI_12_ASG_RUN)
if (SC_ZI_12_ASG_RUN > 0) then
if (SC_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'SC'
else v_p_12 = to_text(v_nr_ore - SC_ZI_12_ASG_RUN)
if (AN_ZI_12_ASG_RUN > 0) then
if (AN_ZI_12_ASG_RUN = v_nr_ore)
then v_p_12 = 'AN'
else v_p_12 = to_text(v_nr_ore - AN_ZI_12_ASG_RUN)
)
/* zi 13
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_13 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_13 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_13_ASG_RUN > 0) then
if (LIBER_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = ' '
else v_p_13 = to_text(v_nr_ore - LIBER_ZI_13_ASG_RUN)
if (CP_ZI_13_ASG_RUN > 0) then
if (CP_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'CP'
else v_p_13 = to_text(v_nr_ore - CP_ZI_13_ASG_RUN)
if (FP_ZI_13_ASG_RUN > 0) then
if (FP_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'FP'
else v_p_13 = to_text(v_nr_ore - FP_ZI_13_ASG_RUN)
if (EV_ZI_13_ASG_RUN > 0) then
if (EV_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'EV'
else v_p_13 = to_text(v_nr_ore - EV_ZI_13_ASG_RUN)
if (CO_ZI_13_ASG_RUN > 0) then
if (CO_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'CO'
else v_p_13 = to_text(v_nr_ore - CO_ZI_13_ASG_RUN)
if (CM_ZI_13_ASG_RUN > 0) then
if (CM_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'CM'
else v_p_13 = to_text(v_nr_ore - CM_ZI_13_ASG_RUN)
if (P_ZI_13_ASG_RUN > 0) then
if (P_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'P'
else v_p_13 = to_text(v_nr_ore - P_ZI_13_ASG_RUN)
if (AN_ZI_13_ASG_RUN > 0) then
if (AN_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'AN'
else v_p_13 = to_text(v_nr_ore - AN_ZI_13_ASG_RUN)
if (SC_ZI_13_ASG_RUN > 0) then
if (SC_ZI_13_ASG_RUN = v_nr_ore)
then v_p_13 = 'SC'
else v_p_13 = to_text(v_nr_ore - SC_ZI_13_ASG_RUN)
)

/* zi 14
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_14 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_14 = to_text(v_nr_ore)
/* este Timp Nelucrat */
if (LIBER_ZI_14_ASG_RUN > 0) then
if (LIBER_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = ' '
else v_p_14 = to_text(v_nr_ore - LIBER_ZI_14_ASG_RUN)
if (CP_ZI_14_ASG_RUN > 0) then
if (CP_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'CP'
else v_p_14 = to_text(v_nr_ore - CP_ZI_14_ASG_RUN)
if (FP_ZI_14_ASG_RUN > 0) then
if (FP_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'FP'
else v_p_14 = to_text(v_nr_ore - FP_ZI_14_ASG_RUN)
if (EV_ZI_14_ASG_RUN > 0) then
if (EV_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'EV'
else v_p_14 = to_text(v_nr_ore - EV_ZI_14_ASG_RUN)
if (CO_ZI_14_ASG_RUN > 0) then
if (CO_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'CO'
else v_p_14 = to_text(v_nr_ore - CO_ZI_14_ASG_RUN)
if (CM_ZI_14_ASG_RUN > 0) then
if (CM_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'CM'
else v_p_14 = to_text(v_nr_ore - CM_ZI_14_ASG_RUN)
if (P_ZI_14_ASG_RUN > 0) then
if (P_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'P'
else v_p_14 = to_text(v_nr_ore - P_ZI_14_ASG_RUN)
if (SC_ZI_14_ASG_RUN > 0) then
if (SC_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'SC'
else v_p_14 = to_text(v_nr_ore - SC_ZI_14_ASG_RUN)
if (AN_ZI_14_ASG_RUN > 0) then
if (AN_ZI_14_ASG_RUN = v_nr_ore)
then v_p_14 = 'AN'
else v_p_14 = to_text(v_nr_ore - AN_ZI_14_ASG_RUN)
)
/* ---------------------------------------------------------------------------------------
End: Prezenta
--------------------------------------------------------------------------------------- */

return
/* Prezenta */
v_p_8,
v_p_9,
v_p_10,
v_p_11,
v_p_12,
v_p_13,
v_p_14

/* End: Formula: PREZENTA_SAPTAMANA_2 */


PREZENTA_SAPTAMANA_3

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREZENTA_SAPTAMANA_3 */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* Liber zi [nr] din Grafic luna corectii */


default for LIBER_ZI_15_ASG_RUN is 0
default for LIBER_ZI_16_ASG_RUN is 0
default for LIBER_ZI_17_ASG_RUN is 0
default for LIBER_ZI_18_ASG_RUN is 0
default for LIBER_ZI_19_ASG_RUN is 0
default for LIBER_ZI_20_ASG_RUN is 0
default for LIBER_ZI_21_ASG_RUN is 0

/* [TN] zi [nr]*/
default for CP_ZI_15_ASG_RUN is 0
default for CP_ZI_16_ASG_RUN is 0
default for CP_ZI_17_ASG_RUN is 0
default for CP_ZI_18_ASG_RUN is 0
default for CP_ZI_19_ASG_RUN is 0
default for CP_ZI_20_ASG_RUN is 0
default for CP_ZI_21_ASG_RUN is 0

default for FP_ZI_15_ASG_RUN is 0


default for FP_ZI_16_ASG_RUN is 0
default for FP_ZI_17_ASG_RUN is 0
default for FP_ZI_18_ASG_RUN is 0
default for FP_ZI_19_ASG_RUN is 0
default for FP_ZI_20_ASG_RUN is 0
default for FP_ZI_21_ASG_RUN is 0

default for EV_ZI_15_ASG_RUN is 0


default for EV_ZI_16_ASG_RUN is 0
default for EV_ZI_17_ASG_RUN is 0
default for EV_ZI_18_ASG_RUN is 0
default for EV_ZI_19_ASG_RUN is 0
default for EV_ZI_20_ASG_RUN is 0
default for EV_ZI_21_ASG_RUN is 0

default for CO_ZI_15_ASG_RUN is 0


default for CO_ZI_16_ASG_RUN is 0
default for CO_ZI_17_ASG_RUN is 0
default for CO_ZI_18_ASG_RUN is 0
default for CO_ZI_19_ASG_RUN is 0
default for CO_ZI_20_ASG_RUN is 0
default for CO_ZI_21_ASG_RUN is 0

default for CM_ZI_15_ASG_RUN is 0


default for CM_ZI_16_ASG_RUN is 0
default for CM_ZI_17_ASG_RUN is 0
default for CM_ZI_18_ASG_RUN is 0
default for CM_ZI_19_ASG_RUN is 0
default for CM_ZI_20_ASG_RUN is 0
default for CM_ZI_21_ASG_RUN is 0

default for P_ZI_15_ASG_RUN is 0


default for P_ZI_16_ASG_RUN is 0
default for P_ZI_17_ASG_RUN is 0
default for P_ZI_18_ASG_RUN is 0
default for P_ZI_19_ASG_RUN is 0
default for P_ZI_20_ASG_RUN is 0
default for P_ZI_21_ASG_RUN is 0

default for AN_ZI_15_ASG_RUN is 0


default for AN_ZI_16_ASG_RUN is 0
default for AN_ZI_17_ASG_RUN is 0
default for AN_ZI_18_ASG_RUN is 0
default for AN_ZI_19_ASG_RUN is 0
default for AN_ZI_20_ASG_RUN is 0
default for AN_ZI_21_ASG_RUN is 0

default for SC_ZI_15_ASG_RUN is 0


default for SC_ZI_16_ASG_RUN is 0
default for SC_ZI_17_ASG_RUN is 0
default for SC_ZI_18_ASG_RUN is 0
default for SC_ZI_19_ASG_RUN is 0
default for SC_ZI_20_ASG_RUN is 0
default for SC_ZI_21_ASG_RUN is 0

/* TN Zi [nr] */
default for TN_ZI_15_ASG_RUN is 0
default for TN_ZI_16_ASG_RUN is 0
default for TN_ZI_17_ASG_RUN is 0
default for TN_ZI_18_ASG_RUN is 0
default for TN_ZI_19_ASG_RUN is 0
default for TN_ZI_20_ASG_RUN is 0
default for TN_ZI_21_ASG_RUN is 0

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_nr_ore = v_durata_muncii
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* zi 15 */
if (v_nr_ore < TN_ZI_15_ASG_RUN) or (TN_ZI_15_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 15 TN = ' + to_text(TN_ZI_15_ASG_RUN)
return v_m1)
/* zi 16 */
if (v_nr_ore < TN_ZI_16_ASG_RUN) or (TN_ZI_16_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 16 TN = ' + to_text(TN_ZI_16_ASG_RUN)
return v_m1)
/* zi 17 */
if (v_nr_ore < TN_ZI_17_ASG_RUN) or (TN_ZI_17_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 17 TN = ' + to_text(TN_ZI_17_ASG_RUN)
return v_m1)
/* zi 18 */
if (v_nr_ore < TN_ZI_18_ASG_RUN) or (TN_ZI_18_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 18 TN = ' + to_text(TN_ZI_18_ASG_RUN)
return v_m1)
/* zi 19 */
if (v_nr_ore < TN_ZI_19_ASG_RUN) or (TN_ZI_19_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 19 TN = ' + to_text(TN_ZI_19_ASG_RUN)
return v_m1)
/* zi 20 */
if (v_nr_ore < TN_ZI_20_ASG_RUN) or (TN_ZI_20_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 20 TN = ' + to_text(TN_ZI_20_ASG_RUN)
return v_m1)
/* zi 21 */
if (v_nr_ore < TN_ZI_21_ASG_RUN) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 21 TN = ' + to_text(TN_ZI_21_ASG_RUN)
return v_m1)
/* ---------------------------------------------------------------------------------------
End: Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Prezenta
--------------------------------------------------------------------------------------- */
/* zi 15
------------------------------------------------------------------------*/
v_zi = to_date('15-' + to_text(PAY_PROC_PERIOD_START_DATE, 'MON') + '-' +
to_text(PAY_PROC_PERIOD_START_DATE, 'YYYY'))
v_p_15 = ' '

/* este in luna curenta */


if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_15 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_15_ASG_RUN > 0) then
if (LIBER_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = ' '
else v_p_15 = to_text(v_nr_ore - LIBER_ZI_15_ASG_RUN)
if (CP_ZI_15_ASG_RUN > 0) then
if (CP_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'CP'
else v_p_15 = to_text(v_nr_ore - CP_ZI_15_ASG_RUN)
if (FP_ZI_15_ASG_RUN > 0) then
if (FP_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'FP'
else v_p_15 = to_text(v_nr_ore - FP_ZI_15_ASG_RUN)
if (EV_ZI_15_ASG_RUN > 0) then
if (EV_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'EV'
else v_p_15 = to_text(v_nr_ore - EV_ZI_15_ASG_RUN)
if (CO_ZI_15_ASG_RUN > 0) then
if (CO_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'CO'
else v_p_15 = to_text(v_nr_ore - CO_ZI_15_ASG_RUN)
if (CM_ZI_15_ASG_RUN > 0) then
if (CM_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'CM'
else v_p_15 = to_text(v_nr_ore - CM_ZI_15_ASG_RUN)
if (P_ZI_15_ASG_RUN > 0) then
if (P_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'P'
else v_p_15 = to_text(v_nr_ore - P_ZI_15_ASG_RUN)
if (SC_ZI_15_ASG_RUN > 0) then
if (SC_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'SC'
else v_p_15 = to_text(v_nr_ore - SC_ZI_15_ASG_RUN)
if (AN_ZI_15_ASG_RUN > 0) then
if (AN_ZI_15_ASG_RUN = v_nr_ore)
then v_p_15 = 'AN'
else v_p_15 = to_text(v_nr_ore - AN_ZI_15_ASG_RUN)
)

/* zi 16
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_16 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_16 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_16_ASG_RUN > 0) then
if (LIBER_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = ' '
else v_p_16 = to_text(v_nr_ore - LIBER_ZI_16_ASG_RUN)
if (CP_ZI_16_ASG_RUN > 0) then
if (CP_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'CP'
else v_p_16 = to_text(v_nr_ore - CP_ZI_16_ASG_RUN)
if (FP_ZI_16_ASG_RUN > 0) then
if (FP_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'FP'
else v_p_16 = to_text(v_nr_ore - FP_ZI_16_ASG_RUN)
if (EV_ZI_16_ASG_RUN > 0) then
if (EV_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'EV'
else v_p_16 = to_text(v_nr_ore - EV_ZI_16_ASG_RUN)
if (CO_ZI_16_ASG_RUN > 0) then
if (CO_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'CO'
else v_p_16 = to_text(v_nr_ore - CO_ZI_16_ASG_RUN)
if (CM_ZI_16_ASG_RUN > 0) then
if (CM_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'CM'
else v_p_16 = to_text(v_nr_ore - CM_ZI_16_ASG_RUN)
if (P_ZI_16_ASG_RUN > 0) then
if (P_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'P'
else v_p_16 = to_text(v_nr_ore - P_ZI_16_ASG_RUN)
if (AN_ZI_16_ASG_RUN > 0) then
if (AN_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'AN'
else v_p_16 = to_text(v_nr_ore - AN_ZI_16_ASG_RUN)
if (SC_ZI_16_ASG_RUN > 0) then
if (SC_ZI_16_ASG_RUN = v_nr_ore)
then v_p_16 = 'SC'
else v_p_16 = to_text(v_nr_ore - SC_ZI_16_ASG_RUN)
)

/* zi 17
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_17 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_17 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_17_ASG_RUN > 0) then
if (LIBER_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = ' '
else v_p_17 = to_text(v_nr_ore - LIBER_ZI_17_ASG_RUN)
if (CP_ZI_17_ASG_RUN > 0) then
if (CP_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'CP'
else v_p_17 = to_text(v_nr_ore - CP_ZI_17_ASG_RUN)
if (FP_ZI_17_ASG_RUN > 0) then
if (FP_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'FP'
else v_p_17 = to_text(v_nr_ore - FP_ZI_17_ASG_RUN)
if (EV_ZI_17_ASG_RUN > 0) then
if (EV_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'EV'
else v_p_17 = to_text(v_nr_ore - EV_ZI_17_ASG_RUN)
if (CO_ZI_17_ASG_RUN > 0) then
if (CO_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'CO'
else v_p_17 = to_text(v_nr_ore - CO_ZI_17_ASG_RUN)
if (CM_ZI_17_ASG_RUN > 0) then
if (CM_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'CM'
else v_p_17 = to_text(v_nr_ore - CM_ZI_17_ASG_RUN)
if (P_ZI_17_ASG_RUN > 0) then
if (P_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'P'
else v_p_17 = to_text(v_nr_ore - P_ZI_17_ASG_RUN)
if (SC_ZI_17_ASG_RUN > 0) then
if (SC_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'SC'
else v_p_17 = to_text(v_nr_ore - SC_ZI_17_ASG_RUN)
if (AN_ZI_17_ASG_RUN > 0) then
if (AN_ZI_17_ASG_RUN = v_nr_ore)
then v_p_17 = 'AN'
else v_p_17 = to_text(v_nr_ore - AN_ZI_17_ASG_RUN)
)

/* zi 18
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_18 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_18 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_18_ASG_RUN > 0) then
if (LIBER_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = ' '
else v_p_18 = to_text(v_nr_ore - LIBER_ZI_18_ASG_RUN)
if (CP_ZI_18_ASG_RUN > 0) then
if (CP_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'CP'
else v_p_18 = to_text(v_nr_ore - CP_ZI_18_ASG_RUN)
if (FP_ZI_18_ASG_RUN > 0) then
if (FP_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'FP'
else v_p_18 = to_text(v_nr_ore - FP_ZI_18_ASG_RUN)
if (EV_ZI_18_ASG_RUN > 0) then
if (EV_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'EV'
else v_p_18 = to_text(v_nr_ore - EV_ZI_18_ASG_RUN)
if (CO_ZI_18_ASG_RUN > 0) then
if (CO_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'CO'
else v_p_18 = to_text(v_nr_ore - CO_ZI_18_ASG_RUN)
if (CM_ZI_18_ASG_RUN > 0) then
if (CM_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'CM'
else v_p_18 = to_text(v_nr_ore - CM_ZI_18_ASG_RUN)
if (P_ZI_18_ASG_RUN > 0) then
if (P_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'P'
else v_p_18 = to_text(v_nr_ore - P_ZI_18_ASG_RUN)
if (AN_ZI_18_ASG_RUN > 0) then
if (AN_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'AN'
else v_p_18 = to_text(v_nr_ore - AN_ZI_18_ASG_RUN)
if (SC_ZI_18_ASG_RUN > 0) then
if (SC_ZI_18_ASG_RUN = v_nr_ore)
then v_p_18 = 'SC'
else v_p_18 = to_text(v_nr_ore - SC_ZI_18_ASG_RUN)
)

/* zi 19
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_19 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_19 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_19_ASG_RUN > 0) then
if (LIBER_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = ' '
else v_p_19 = to_text(v_nr_ore - LIBER_ZI_19_ASG_RUN)
if (CP_ZI_19_ASG_RUN > 0) then
if (CP_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'CP'
else v_p_19 = to_text(v_nr_ore - CP_ZI_19_ASG_RUN)
if (FP_ZI_19_ASG_RUN > 0) then
if (FP_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'FP'
else v_p_19 = to_text(v_nr_ore - FP_ZI_19_ASG_RUN)
if (EV_ZI_19_ASG_RUN > 0) then
if (EV_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'EV'
else v_p_19 = to_text(v_nr_ore - EV_ZI_19_ASG_RUN)
if (CO_ZI_19_ASG_RUN > 0) then
if (CO_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'CO'
else v_p_19 = to_text(v_nr_ore - CO_ZI_19_ASG_RUN)
if (CM_ZI_19_ASG_RUN > 0) then
if (CM_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'CM'
else v_p_19 = to_text(v_nr_ore - CM_ZI_19_ASG_RUN)
if (P_ZI_19_ASG_RUN > 0) then
if (P_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'P'
else v_p_19 = to_text(v_nr_ore - P_ZI_19_ASG_RUN)
if (SC_ZI_19_ASG_RUN > 0) then
if (SC_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'SC'
else v_p_19 = to_text(v_nr_ore - SC_ZI_19_ASG_RUN)
if (AN_ZI_19_ASG_RUN > 0) then
if (AN_ZI_19_ASG_RUN = v_nr_ore)
then v_p_19 = 'AN'
else v_p_19 = to_text(v_nr_ore - AN_ZI_19_ASG_RUN)
)
/* zi 20
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_20 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_20 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_20_ASG_RUN > 0) then
if (LIBER_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = ' '
else v_p_20 = to_text(v_nr_ore - LIBER_ZI_20_ASG_RUN)
if (CP_ZI_20_ASG_RUN > 0) then
if (CP_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'CP'
else v_p_20 = to_text(v_nr_ore - CP_ZI_20_ASG_RUN)
if (FP_ZI_20_ASG_RUN > 0) then
if (FP_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'FP'
else v_p_20 = to_text(v_nr_ore - FP_ZI_20_ASG_RUN)
if (EV_ZI_20_ASG_RUN > 0) then
if (EV_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'EV'
else v_p_20 = to_text(v_nr_ore - EV_ZI_20_ASG_RUN)
if (CO_ZI_20_ASG_RUN > 0) then
if (CO_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'CO'
else v_p_20 = to_text(v_nr_ore - CO_ZI_20_ASG_RUN)
if (CM_ZI_20_ASG_RUN > 0) then
if (CM_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'CM'
else v_p_20 = to_text(v_nr_ore - CM_ZI_20_ASG_RUN)
if (P_ZI_20_ASG_RUN > 0) then
if (P_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'P'
else v_p_20 = to_text(v_nr_ore - P_ZI_20_ASG_RUN)
if (AN_ZI_20_ASG_RUN > 0) then
if (AN_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'AN'
else v_p_20 = to_text(v_nr_ore - AN_ZI_20_ASG_RUN)
if (SC_ZI_20_ASG_RUN > 0) then
if (SC_ZI_20_ASG_RUN = v_nr_ore)
then v_p_20 = 'SC'
else v_p_20 = to_text(v_nr_ore - SC_ZI_20_ASG_RUN)
)

/* zi 21
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_21 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_21 = to_text(v_nr_ore)
/* este Timp Nelucrat */
if (LIBER_ZI_21_ASG_RUN > 0) then
if (LIBER_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = ' '
else v_p_21 = to_text(v_nr_ore - LIBER_ZI_21_ASG_RUN)
if (CP_ZI_21_ASG_RUN > 0) then
if (CP_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'CP'
else v_p_21 = to_text(v_nr_ore - CP_ZI_21_ASG_RUN)
if (FP_ZI_21_ASG_RUN > 0) then
if (FP_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'FP'
else v_p_21 = to_text(v_nr_ore - FP_ZI_21_ASG_RUN)
if (EV_ZI_21_ASG_RUN > 0) then
if (EV_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'EV'
else v_p_21 = to_text(v_nr_ore - EV_ZI_21_ASG_RUN)
if (CO_ZI_21_ASG_RUN > 0) then
if (CO_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'CO'
else v_p_21 = to_text(v_nr_ore - CO_ZI_21_ASG_RUN)
if (CM_ZI_21_ASG_RUN > 0) then
if (CM_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'CM'
else v_p_21 = to_text(v_nr_ore - CM_ZI_21_ASG_RUN)
if (P_ZI_21_ASG_RUN > 0) then
if (P_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'P'
else v_p_21 = to_text(v_nr_ore - P_ZI_21_ASG_RUN)
if (SC_ZI_21_ASG_RUN > 0) then
if (SC_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'SC'
else v_p_21 = to_text(v_nr_ore - SC_ZI_21_ASG_RUN)
if (AN_ZI_21_ASG_RUN > 0) then
if (AN_ZI_21_ASG_RUN = v_nr_ore)
then v_p_21 = 'AN'
else v_p_21 = to_text(v_nr_ore - AN_ZI_21_ASG_RUN)
)
/* ---------------------------------------------------------------------------------------
End: Prezenta
--------------------------------------------------------------------------------------- */

return
/* Prezenta */
v_p_15,
v_p_16,
v_p_17,
v_p_18,
v_p_19,
v_p_20,
v_p_21

/* End: Formula: PREZENTA_SAPTAMANA_3 */


PREZENTA_SAPTAMANA_5

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PREZENTA_SAPTAMANA_5 */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* Liber zi [nr] din Grafic luna corectii */


default for LIBER_ZI_29_ASG_RUN is 0
default for LIBER_ZI_30_ASG_RUN is 0
default for LIBER_ZI_31_ASG_RUN is 0

/* [TN] zi [nr]*/
default for CP_ZI_29_ASG_RUN is 0
default for CP_ZI_30_ASG_RUN is 0
default for CP_ZI_31_ASG_RUN is 0

default for FP_ZI_29_ASG_RUN is 0


default for FP_ZI_30_ASG_RUN is 0
default for FP_ZI_31_ASG_RUN is 0

default for EV_ZI_29_ASG_RUN is 0


default for EV_ZI_30_ASG_RUN is 0
default for EV_ZI_31_ASG_RUN is 0

default for CO_ZI_29_ASG_RUN is 0


default for CO_ZI_30_ASG_RUN is 0
default for CO_ZI_31_ASG_RUN is 0

default for CM_ZI_29_ASG_RUN is 0


default for CM_ZI_30_ASG_RUN is 0
default for CM_ZI_31_ASG_RUN is 0

default for P_ZI_29_ASG_RUN is 0


default for P_ZI_30_ASG_RUN is 0
default for P_ZI_31_ASG_RUN is 0

default for AN_ZI_29_ASG_RUN is 0


default for AN_ZI_30_ASG_RUN is 0
default for AN_ZI_31_ASG_RUN is 0

default for SC_ZI_29_ASG_RUN is 0


default for SC_ZI_30_ASG_RUN is 0
default for SC_ZI_31_ASG_RUN is 0

/* TN Zi [nr] */
default for TN_ZI_29_ASG_RUN is 0
default for TN_ZI_30_ASG_RUN is 0
default for TN_ZI_31_ASG_RUN is 0

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_nr_ore = v_durata_muncii
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* zi 29 */
if (v_nr_ore < TN_ZI_29_ASG_RUN) or (TN_ZI_29_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 29 TN = ' + to_text(TN_ZI_29_ASG_RUN)
return v_m1)
/* zi 30 */
if (v_nr_ore < TN_ZI_30_ASG_RUN) or (TN_ZI_30_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 30 TN = ' + to_text(TN_ZI_30_ASG_RUN)
return v_m1)
/* zi 31 */
if (v_nr_ore < TN_ZI_31_ASG_RUN) or (TN_ZI_31_ASG_RUN < 0) then
(v_m1 = ELEMENT_NAME + ' Eroare Zi 31 TN = ' + to_text(TN_ZI_31_ASG_RUN)
return v_m1)
/* ---------------------------------------------------------------------------------------
End: Verificare Pontaj Calculat
--------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
Prezenta
--------------------------------------------------------------------------------------- */
/* zi 29
------------------------------------------------------------------------*/
v_zi = to_date('28-' + to_text(PAY_PROC_PERIOD_START_DATE, 'MON') + '-' +
to_text(PAY_PROC_PERIOD_START_DATE, 'YYYY'))
v_zi = ADD_DAYS(v_zi, 1)
v_p_29 = ' '

/* este in luna curenta */


if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_29 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_29_ASG_RUN > 0) then
if (LIBER_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = ' '
else v_p_29 = to_text(v_nr_ore - LIBER_ZI_29_ASG_RUN)
if (CP_ZI_29_ASG_RUN > 0) then
if (CP_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'CP'
else v_p_29 = to_text(v_nr_ore - CP_ZI_29_ASG_RUN)
if (FP_ZI_29_ASG_RUN > 0) then
if (FP_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'FP'
else v_p_29 = to_text(v_nr_ore - FP_ZI_29_ASG_RUN)
if (EV_ZI_29_ASG_RUN > 0) then
if (EV_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'EV'
else v_p_29 = to_text(v_nr_ore - EV_ZI_29_ASG_RUN)
if (CO_ZI_29_ASG_RUN > 0) then
if (CO_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'CO'
else v_p_29 = to_text(v_nr_ore - CO_ZI_29_ASG_RUN)
if (CM_ZI_29_ASG_RUN > 0) then
if (CM_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'CM'
else v_p_29 = to_text(v_nr_ore - CM_ZI_29_ASG_RUN)
if (P_ZI_29_ASG_RUN > 0) then
if (P_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'P'
else v_p_29 = to_text(v_nr_ore - P_ZI_29_ASG_RUN)
if (SC_ZI_29_ASG_RUN > 0) then
if (SC_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'SC'
else v_p_29 = to_text(v_nr_ore - SC_ZI_29_ASG_RUN)
if (AN_ZI_29_ASG_RUN > 0) then
if (AN_ZI_29_ASG_RUN = v_nr_ore)
then v_p_29 = 'AN'
else v_p_29 = to_text(v_nr_ore - AN_ZI_29_ASG_RUN)
)

/* zi 30
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_30 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_30 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_30_ASG_RUN > 0) then
if (LIBER_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = ' '
else v_p_30 = to_text(v_nr_ore - LIBER_ZI_30_ASG_RUN)
if (CP_ZI_30_ASG_RUN > 0) then
if (CP_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'CP'
else v_p_30 = to_text(v_nr_ore - CP_ZI_30_ASG_RUN)
if (FP_ZI_30_ASG_RUN > 0) then
if (FP_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'FP'
else v_p_30 = to_text(v_nr_ore - FP_ZI_30_ASG_RUN)
if (EV_ZI_30_ASG_RUN > 0) then
if (EV_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'EV'
else v_p_30 = to_text(v_nr_ore - EV_ZI_30_ASG_RUN)
if (CO_ZI_30_ASG_RUN > 0) then
if (CO_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'CO'
else v_p_30 = to_text(v_nr_ore - CO_ZI_30_ASG_RUN)
if (CM_ZI_30_ASG_RUN > 0) then
if (CM_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'CM'
else v_p_30 = to_text(v_nr_ore - CM_ZI_30_ASG_RUN)
if (P_ZI_30_ASG_RUN > 0) then
if (P_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'P'
else v_p_30 = to_text(v_nr_ore - P_ZI_30_ASG_RUN)
if (AN_ZI_30_ASG_RUN > 0) then
if (AN_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'AN'
else v_p_30 = to_text(v_nr_ore - AN_ZI_30_ASG_RUN)
if (SC_ZI_30_ASG_RUN > 0) then
if (SC_ZI_30_ASG_RUN = v_nr_ore)
then v_p_30 = 'SC'
else v_p_30 = to_text(v_nr_ore - SC_ZI_30_ASG_RUN)
)

/* zi 31
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
v_p_31 = ' '

/* este in perioada de TN */
if (v_zi <= PAY_PROC_PERIOD_END_DATE) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_p_31 = to_text(v_nr_ore)

/* este Timp Nelucrat */


if (LIBER_ZI_31_ASG_RUN > 0) then
if (LIBER_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = ' '
else v_p_31 = to_text(v_nr_ore - LIBER_ZI_31_ASG_RUN)
if (CP_ZI_31_ASG_RUN > 0) then
if (CP_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'CP'
else v_p_31 = to_text(v_nr_ore - CP_ZI_31_ASG_RUN)
if (FP_ZI_31_ASG_RUN > 0) then
if (FP_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'FP'
else v_p_31 = to_text(v_nr_ore - FP_ZI_31_ASG_RUN)
if (EV_ZI_31_ASG_RUN > 0) then
if (EV_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'EV'
else v_p_31 = to_text(v_nr_ore - EV_ZI_31_ASG_RUN)
if (CO_ZI_31_ASG_RUN > 0) then
if (CO_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'CO'
else v_p_31 = to_text(v_nr_ore - CO_ZI_31_ASG_RUN)
if (CM_ZI_31_ASG_RUN > 0) then
if (CM_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'CM'
else v_p_31 = to_text(v_nr_ore - CM_ZI_31_ASG_RUN)
if (P_ZI_31_ASG_RUN > 0) then
if (P_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'P'
else v_p_31 = to_text(v_nr_ore - P_ZI_31_ASG_RUN)
if (SC_ZI_31_ASG_RUN > 0) then
if (SC_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'SC'
else v_p_31 = to_text(v_nr_ore - SC_ZI_31_ASG_RUN)
if (AN_ZI_31_ASG_RUN > 0) then
if (AN_ZI_31_ASG_RUN = v_nr_ore)
then v_p_31 = 'AN'
else v_p_31 = to_text(v_nr_ore - AN_ZI_31_ASG_RUN)
)
/* ---------------------------------------------------------------------------------------
End: Prezenta
--------------------------------------------------------------------------------------- */

return
/* Prezenta */
v_p_29,
v_p_30,
v_p_31

/* End: Formula: PREZENTA_SAPTAMANA_5 */

PRIMA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PRIMA */

default for SUMA is 0


default for ACORDAT_IN_AVANS is 'D'
default for AVANS is 0
default for Data_plata is '01-FEB-1900' (DATE)
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)

inputs are
SUMA,
ACORDAT_IN_AVANS,
AVANS,
Data_plata

/* --------------------------
Suma
--------------------------- */

v_suma = SUMA

/* --------------------------
End: Suma
--------------------------- */

/* --------------------------
avans
----------------------------- */

if ACORDAT_IN_AVANS = 'D' then


(
v_lansare_avans = ELEMENT_NAME
v_data_plata = DATA_PLATA
if DATA_PLATA was defaulted then v_data_plata = PAY_PROC_PERIOD_START_DATE
v_avans = v_suma
if AVANS was not defaulted then v_avans = AVANS
)

/* --------------------------
end: avans
----------------------------- */

return
v_suma,
/* Avans Prima */
v_avans, /* Conta Acordare avans salarial */ /* Conta Avans salarial */
v_data_plata, /* Conta Acordare avans salarial */
v_lansare_avans

/* End: Formula: PRIMA */

PRIMA_BRUTA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PRIMA_BRUTA */

default for SUMA_ACORDATA is 0


default for ACORDAT_IN_AVANS is 'D'
default for MONEDA is 'RON'

default for SAL_MEDIU_ECONOMIE is 0


default for NR_SALARII_CAS is 5
default for CAS_ASIGURAT is 0
default for PROCENT_IMPOZIT_SAL is 0
default for SANATATE_ASIGURAT is 0
default for PROC_SOMAJ_ASIG is 0

default for DEDUCERE_BAZA is 0


default for DEDUCERE_DEPENDENT is 0

default for NR_MAX_PERS_INTRETINERE is 4

default for VENIT_BRUT_1 is 1000


default for VENIT_BRUT_2 is 2000
default for VENIT_BRUT_3 is 3000

default for SALARIU_BAZA_LUNAR_ASG_RUN is 0


default for SALARIU_BAZA_NEGOCIAT_ASG_RUN is 0
default for SPORURI_NEGOCIATE_PROCENTE_ASG_RUN is 0
default for SPOR_CASIER_PROCENT_ASG_RUN is 0

default for CURS_EUR_RON_PRIME is 0


default for CURS_USD_RON_PRIME is 0

default for ELEMENT_NAME is ' '

inputs are
SUMA_ACORDATA,
ACORDAT_IN_AVANS,
MONEDA

v_prima = SUMA_ACORDATA

if MONEDA = 'USD' then v_prima = round( SUMA_ACORDATA * CURS_USD_RON_PRIME)


if MONEDA = 'EUR' then v_prima = round( SUMA_ACORDATA * CURS_EUR_RON_PRIME)

SMED = SAL_MEDIU_ECONOMIE
NSAL = NR_SALARII_CAS
CAS = CAS_ASIGURAT / 100
IMP = PROCENT_IMPOZIT_SAL / 100
SAN = SANATATE_ASIGURAT / 100
SOM = PROC_SOMAJ_ASIG

NET_VENIT_BRUT_1 = 737
NET_VENIT_BRUT_3 = 2092
NET_PLAFON_CAS = 3754

/* ------------------------------------------------------------------
persoane in intretinere
------------------------------------------------------------------ */
v_nr_pers = COEF_DED_SUPLIM() / COEFICIENT_DEDUCERE_PERSOANA_INTRETINERE
if (v_nr_pers > NR_MAX_PERS_INTRETINERE) then v_nr_pers = NR_MAX_PERS_INTRETINERE
/* ------------------------------------------------------------------
End: persoane in intretinere
------------------------------------------------------------------ */

y = DEDUCERE_BAZA + DEDUCERE_DEPENDENT * v_nr_pers

v_sp_procente = SPORURI_NEGOCIATE_PROCENTE_ASG_RUN
v_salariu = SALARIU_BAZA_LUNAR_ASG_RUN
v_salariu_negociat = SALARIU_BAZA_NEGOCIAT_ASG_RUN
v_sp_casier_pr = SPOR_CASIER_PROCENT_ASG_RUN
v_m1 = ELEMENT_NAME
/* ------------------------------------------------------------------
calcul salariu net cu prima
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Venit brut
------------------------------------------------------------------ */
v_prime = v_prima
v_salarii = v_salariu
v_sporuri = round(v_salariu * v_sp_procente / 100)

v_sp_casier = round(v_salariu_negociat * v_sp_casier_pr / 100)


v_baza_somaj = v_salariu + v_sp_casier
v_somaj = round(v_baza_somaj * PROC_SOMAJ_ASIG)

v_baza_cas_neplafonata = v_salarii + v_sporuri + v_prime


v_baza_cas = v_baza_cas_neplafonata
/* plafonare */
if (SMED * NSAL < v_baza_cas) then v_baza_cas = SMED * NSAL
v_cas = round((CAS_ASIGURAT / 100) * v_baza_cas)

v_profit = 0
v_baza_sanatate = v_baza_cas_neplafonata + v_profit
v_sanatate = round((SANATATE_ASIGURAT / 100) * v_baza_sanatate)

v_cm_indemnizatie = 0
v_venit_brut = v_baza_sanatate + v_cm_indemnizatie

/* ------------------------------------------------------------------
End: Venit brut
------------------------------------------------------------------ */

/* Formula: DEDUCERE_PERSONALA_1 */

/* ------------------------------------------------------------------
persoane in intretinere
------------------------------------------------------------------ */
v_nr_pers = COEF_DED_SUPLIM() / COEFICIENT_DEDUCERE_PERSOANA_INTRETINERE
if (v_nr_pers > NR_MAX_PERS_INTRETINERE) then v_nr_pers = NR_MAX_PERS_INTRETINERE
/* ------------------------------------------------------------------
End: persoane in intretinere
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Deducere personala
------------------------------------------------------------------ */
v_deducere = 0
v_VBL = v_venit_brut
v_deducere = DEDUCERE_BAZA + DEDUCERE_DEPENDENT * v_nr_pers
if (v_VBL > VENIT_BRUT_1 and v_VBL <= VENIT_BRUT_3) then
v_deducere = roundup( (v_deducere * (1-( v_VBL - VENIT_BRUT_1)/ VENIT_BRUT_2))/ 100,1) * 100

if (v_VBL > VENIT_BRUT_3) then v_deducere = 0


/* ------------------------------------------------------------------
End: Deducere personala
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Cotizatie Sindicat
------------------------------------------------------------------ */
v_cotizatie_sindicat = 0
/* are cotizatie sindicat
if (COTIZATIE_SINDICAT_COUNT > 0) then v_cotizatie_sindicat = COTIZATIE_SINDICAT_ASG_RUN
*/
/* ------------------------------------------------------------------
End: Cotizatie Sindicat
------------------------------------------------------------------ */

/* End: Formula: DEDUCERE_PERSONALA_1 */

/* ------------------------------------------------------------------
Salariu net
------------------------------------------------------------------ */

v_venit_net = v_venit_brut - (v_sanatate + v_cas + v_somaj)


v_venit_impozabil = v_venit_net - (v_deducere + v_cotizatie_sindicat)

Brut_impozabil = greatest(round(v_venit_impozabil, 0), 0)

impoz_sal = round(Brut_impozabil * (PROCENT_IMPOZIT_SAL / 100))


v_impozit = greatest(impoz_sal,0)

v_salariu_net = v_venit_brut - (v_impozit + v_sanatate + v_cas + v_somaj)

/* ------------------------------------------------------------------
End: Salariu net
------------------------------------------------------------------ */

v_salariu_net_cu_prima = v_salariu_net
v_m1 = v_m1 + ' salariu_net_cu_prima =' + to_text(v_salariu_net)

/* ------------------------------------------------------------------
End: calcul salariu net cu prima
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
calcul salariu net fara prima
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Venit brut
------------------------------------------------------------------ */
v_prime = 0
v_salarii = v_salariu
v_sporuri = round(v_salariu * v_sp_procente / 100)

v_sp_casier = round(v_salariu_negociat * v_sp_casier_pr / 100)


v_baza_somaj = v_salariu + v_sp_casier
v_somaj = round(v_baza_somaj * PROC_SOMAJ_ASIG)

v_baza_cas_neplafonata = v_salarii + v_sporuri + v_prime


v_baza_cas = v_baza_cas_neplafonata
/* plafonare */
if (SMED * NSAL < v_baza_cas) then v_baza_cas = SMED * NSAL
v_cas = round((CAS_ASIGURAT / 100) * v_baza_cas)

v_profit = 0
v_baza_sanatate = v_baza_cas_neplafonata + v_profit
v_sanatate = round((SANATATE_ASIGURAT / 100) * v_baza_sanatate)

v_cm_indemnizatie = 0
v_venit_brut = v_baza_sanatate + v_cm_indemnizatie

/* ------------------------------------------------------------------
End: Venit brut
------------------------------------------------------------------ */

/* Formula: DEDUCERE_PERSONALA_1 */

/* ------------------------------------------------------------------
persoane in intretinere
------------------------------------------------------------------ */
v_nr_pers = COEF_DED_SUPLIM() / COEFICIENT_DEDUCERE_PERSOANA_INTRETINERE
if (v_nr_pers > NR_MAX_PERS_INTRETINERE) then v_nr_pers = NR_MAX_PERS_INTRETINERE
/* ------------------------------------------------------------------
End: persoane in intretinere
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Deducere personala
------------------------------------------------------------------ */
v_deducere = 0
v_VBL = v_venit_brut
v_deducere = DEDUCERE_BAZA + DEDUCERE_DEPENDENT * v_nr_pers

if (v_VBL > VENIT_BRUT_1 and v_VBL <= VENIT_BRUT_3) then


v_deducere = roundup( (v_deducere * (1-( v_VBL - VENIT_BRUT_1)/ VENIT_BRUT_2))/ 100,1) * 100

if (v_VBL > VENIT_BRUT_3) then v_deducere = 0


/* ------------------------------------------------------------------
End: Deducere personala
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Cotizatie Sindicat
------------------------------------------------------------------ */
v_cotizatie_sindicat = 0
/* are cotizatie sindicat
if (COTIZATIE_SINDICAT_COUNT > 0) then v_cotizatie_sindicat = COTIZATIE_SINDICAT_ASG_RUN
*/
/* ------------------------------------------------------------------
End: Cotizatie Sindicat
------------------------------------------------------------------ */

/* End: Formula: DEDUCERE_PERSONALA_1 */

/* ------------------------------------------------------------------
Salariu net
------------------------------------------------------------------ */

v_venit_net = v_venit_brut - (v_sanatate + v_cas + v_somaj)


v_venit_impozabil = v_venit_net - (v_deducere + v_cotizatie_sindicat)

Brut_impozabil = greatest(round(v_venit_impozabil, 0), 0)

impoz_sal = round(Brut_impozabil * (PROCENT_IMPOZIT_SAL / 100))


v_impozit = greatest(impoz_sal,0)

v_salariu_net = v_venit_brut - (v_impozit + v_sanatate + v_cas + v_somaj)

/* ------------------------------------------------------------------
End: Salariu net
------------------------------------------------------------------ */

v_salariu_net_fara_prima = v_salariu_net
v_m1 = v_m1 + ' salariu_net_fara_prima =' + to_text(v_salariu_net)

/* ------------------------------------------------------------------
End: calcul salariu net fara prima
------------------------------------------------------------------ */
v_prima_neta = v_salariu_net_cu_prima - v_salariu_net_fara_prima
v_m1 = v_m1 + ' prima_neta =' + to_text(v_prima_neta)

if ACORDAT_IN_AVANS = 'D' THEN


(
v_lansare_avans = ELEMENT_NAME
v_avans = v_prima_neta
)

return
/* Prima bruta */
v_prima,
/* Avans prima bruta */
v_lansare_avans,
v_avans,

v_m1

/* End: Formula: PRIMA_BRUTA */


PRIMA_NETA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: PRIMA_NETA vs. 1 jan 06*/

default for SAL_MEDIU_ECONOMIE is 0


default for NR_SALARII_CAS is 5
default for CAS_ASIGURAT is 0
default for PROCENT_IMPOZIT_SAL is 0
default for SANATATE_ASIGURAT is 0
default for PROC_SOMAJ_ASIG is 0

default for DEDUCERE_BAZA is 0


default for DEDUCERE_DEPENDENT is 0

default for NR_MAX_PERS_INTRETINERE is 4

default for VENIT_BRUT_1 is 1000


default for VENIT_BRUT_2 is 2000
default for VENIT_BRUT_3 is 3000

default for SALARIU_BAZA_LUNAR_ASG_RUN is 0


default for SALARIU_BAZA_NEGOCIAT_ASG_RUN is 0
default for SPORURI_NEGOCIATE_PROCENTE_ASG_RUN is 0
default for SPOR_CASIER_PROCENT_ASG_RUN is 0

default for SUMA_ACORDATA is 0

default for CURS_EUR_RON_PRIME is 0


default for CURS_USD_RON_PRIME is 0

default for ACORDAT_IN_AVANS is 'D'


default for MONEDA is 'RON'

default for ELEMENT_NAME is ' '

inputs are
SUMA_ACORDATA,
ACORDAT_IN_AVANS,
MONEDA

SMED = SAL_MEDIU_ECONOMIE
NSAL = NR_SALARII_CAS
CAS = CAS_ASIGURAT / 100
IMP = PROCENT_IMPOZIT_SAL / 100
SAN = SANATATE_ASIGURAT / 100
SOM = PROC_SOMAJ_ASIG

NET_VENIT_BRUT_1 = 737
NET_VENIT_BRUT_3 = 2092
NET_PLAFON_CAS = 3754

/* ------------------------------------------------------------------
persoane in intretinere
------------------------------------------------------------------ */
v_nr_pers = COEF_DED_SUPLIM() / COEFICIENT_DEDUCERE_PERSOANA_INTRETINERE
if (v_nr_pers > NR_MAX_PERS_INTRETINERE) then v_nr_pers = NR_MAX_PERS_INTRETINERE
/* ------------------------------------------------------------------
End: persoane in intretinere
------------------------------------------------------------------ */

y = DEDUCERE_BAZA + DEDUCERE_DEPENDENT * v_nr_pers

/* ------------------------------------------------------------------
calcul salariu net prezumptiv
------------------------------------------------------------------ */

v_m1 = ELEMENT_NAME + ':'


v_sp_procente = SPORURI_NEGOCIATE_PROCENTE_ASG_RUN
v_salariu = SALARIU_BAZA_LUNAR_ASG_RUN
v_salariu_negociat = SALARIU_BAZA_NEGOCIAT_ASG_RUN
v_sp_casier_pr = SPOR_CASIER_PROCENT_ASG_RUN
SPPR = v_sp_casier_pr / 100

/* ------------------------------------------------------------------
Venit brut
------------------------------------------------------------------ */
v_prime = 0
v_salarii = v_salariu
v_sporuri = round(v_salariu * v_sp_procente / 100)

v_sp_casier = round(v_salariu_negociat * SPPR)


v_baza_somaj = v_salariu + v_sp_casier
v_somaj = round(v_baza_somaj * SOM)
/*
v_sp_casier = v_salariu * SPPR
v_baza_somaj = v_salariu + v_salariu * SPPR = v_salariu * (1 + SPPR)
v_somaj = v_baza_somaj * SOM = v_salariu * (1 + SPPR) * SOM
*/
v_baza_cas_neplafonata = v_salarii + v_sporuri + v_prime
v_baza_cas = v_baza_cas_neplafonata
/* plafonare */
if (SMED * NSAL < v_baza_cas) then v_baza_cas = SMED * NSAL
v_cas = round((CAS_ASIGURAT / 100) * v_baza_cas)

v_profit = 0
v_baza_sanatate = v_baza_cas_neplafonata + v_profit
v_sanatate = round((SANATATE_ASIGURAT / 100) * v_baza_sanatate)

v_cm_indemnizatie = 0
v_venit_brut = v_baza_sanatate + v_cm_indemnizatie
v_m1 = v_m1 + ' v_venit_brut_fara_prima=' + to_text(v_venit_brut)

/* ------------------------------------------------------------------
End: Venit brut
------------------------------------------------------------------ */

/* Formula: DEDUCERE_PERSONALA_1 */

/* ------------------------------------------------------------------
persoane in intretinere
------------------------------------------------------------------ */
v_nr_pers = COEF_DED_SUPLIM() / COEFICIENT_DEDUCERE_PERSOANA_INTRETINERE
if (v_nr_pers > NR_MAX_PERS_INTRETINERE) then v_nr_pers = NR_MAX_PERS_INTRETINERE
/* ------------------------------------------------------------------
End: persoane in intretinere
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Deducere personala
------------------------------------------------------------------ */
v_deducere = 0
v_VBL = v_venit_brut
v_deducere = DEDUCERE_BAZA + DEDUCERE_DEPENDENT * v_nr_pers

if (v_VBL > VENIT_BRUT_1 and v_VBL <= VENIT_BRUT_3) then


v_deducere = roundup( (v_deducere * (1-( v_VBL - VENIT_BRUT_1)/ VENIT_BRUT_2))/ 100,1) * 100

if (v_VBL > VENIT_BRUT_3) then v_deducere = 0


/* ------------------------------------------------------------------
End: Deducere personala
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Cotizatie Sindicat
------------------------------------------------------------------ */
v_cotizatie_sindicat = 0
/* are cotizatie sindicat
if (COTIZATIE_SINDICAT_COUNT > 0) then v_cotizatie_sindicat = COTIZATIE_SINDICAT_ASG_RUN
*/
/* ------------------------------------------------------------------
End: Cotizatie Sindicat
------------------------------------------------------------------ */

/* End: Formula: DEDUCERE_PERSONALA_1 */

/* ------------------------------------------------------------------
Salariu net
------------------------------------------------------------------ */

v_venit_net = v_venit_brut - (v_sanatate + v_cas + v_somaj)


v_venit_impozabil = v_venit_net - (v_deducere + v_cotizatie_sindicat)

Brut_impozabil = greatest(round(v_venit_impozabil, 0), 0)


impoz_sal = round(Brut_impozabil * (PROCENT_IMPOZIT_SAL / 100))
v_impozit = greatest(impoz_sal,0)
v_salariu_net = v_venit_brut - (v_impozit + v_sanatate + v_cas + v_somaj)
v_m1 = v_m1 + ' salariu_net_fara_prima=' + to_text(v_salariu_net)

/* ------------------------------------------------------------------
End: Salariu net
------------------------------------------------------------------ */

v_venit_brut_i = v_venit_brut

/* ------------------------------------------------------------------
End: calcul salariu net prezumptiv
------------------------------------------------------------------ */

v_suma_acordata = SUMA_ACORDATA

if MONEDA = 'USD' then v_suma_acordata = SUMA_ACORDATA * CURS_USD_RON_PRIME


if MONEDA = 'EUR' then v_suma_acordata = SUMA_ACORDATA * CURS_EUR_RON_PRIME

NET = v_salariu_net + v_suma_acordata


v_m1 = v_m1 + ' salariu_net_cu_prima=' + to_text(NET)

SOM = (1 + SPPR) * SOM

if (NET >= NET_PLAFON_CAS) then


x = (NET + CAS * SMED * NSAL * (1 - IMP)) / ((1 - SAN - SOM) * (1 - IMP))

if (NET >= NET_VENIT_BRUT_3) and (NET < NET_PLAFON_CAS) then


x = NET/((1-SAN-CAS-SOM)*(1-IMP))

if (NET >= NET_VENIT_BRUT_1) and (NET < NET_VENIT_BRUT_3) then


x = (NET - y * (1 + VENIT_BRUT_1 / VENIT_BRUT_2) * IMP) /
( ((1 - (SAN + CAS + SOM)) * (1 - IMP)) - (y / VENIT_BRUT_2 * IMP))

if (NET < NET_VENIT_BRUT_1) then


x = (NET - y * IMP) / ((1 - (SAN + CAS + SOM)) * (1 - IMP))

v_venit_brut = round(x)
v_m1 = v_m1 + ' venit_brut_cu_prima=' + to_text(v_venit_brut)

v_prima_bruta = v_venit_brut - v_venit_brut_i

if ACORDAT_IN_AVANS = 'D' then


(
v_lansare_avans = ELEMENT_NAME
v_avans = v_suma_acordata
)

return
v_prima_bruta,
v_lansare_avans,
v_avans,
v_m1

/* End: Formula: PRIMA_NETA */


PRIME

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: PRIME */

default for PRIME_ASG_MONTH is 0

v_prime = PRIME_ASG_MONTH

if (v_prime <> 0) then v_suma = v_prime

return v_prime,

/* Conta Prime */

v_suma

/* End: Formula: PRIME */

PROFIT

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *


* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: PROFIT */

default for PROFIT_ASG_MONTH is 0

v_profit = PROFIT_ASG_MONTH

if (v_profit <> 0) then v_suma = v_profit

return

v_profit,

/* Conta profit */

/* Conta Profit debitare centrala */

v_suma

/* End: Formula: PROFIT */

RATA_1

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: RATA_1 */

default for REST_PLATA_2_ASG_MONTH is 0


default for ELEMENT_NAME is ' '
default for RATA is 0
default for RATA_1_NEACOPERIT_ASG_ITD is 0

inputs are RATA

v_disponibil = REST_PLATA_2_ASG_MONTH
v_rata = RATA
v_neacoperit_initial = RATA_1_NEACOPERIT_ASG_ITD

v_rata_de_platit = (v_rata + v_neacoperit_initial)

v_rata_retinuta = least(v_disponibil,v_rata_de_platit)

v_neacoperit_final = v_rata_de_platit - v_rata_retinuta


if (v_neacoperit_final > 0) then
v_mesaj_1 = ELEMENT_NAME + ' : Retinere neacoperita = ' + to_text(v_neacoperit_final)

return
v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta

/* End: Formula: RATA_1 */

RATE

/********************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: RATE */

default for RATE_ASG_MONTH is 0


default for POPRIRE_RATE_LUNA_ASG_RUN is 0

if POPRIRE_RATE_LUNA_ASG_RUN <>0 then v_lans_poprire_rate_luna = ELEMENT_NAME

v_rate = RATE_ASG_MONTH

if (v_rate <> 0) then v_suma = v_rate

return
v_rate,
v_lans_poprire_rate_luna, /* Poprire rate luna */

/* Conta rate */
v_suma

/* End: Formula: RATE */


REST_PLATA_1

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: REST_PLATA_1 */

default for REST_PLATA_1_ASG_MONTH is 0


default for DEBITE_DIN_SALARIU_ASG_ITD is 0
default for ELEMENT_NAME is ' '
default for STINGERE_DEBIT_SALARIU_ASG_MONTH is 0

if (STINGERE_DEBIT_SALARIU_ASG_MONTH <> 0) then


(v_sting_debit = STINGERE_DEBIT_SALARIU_ASG_MONTH)

v_debit_anterior = DEBITE_DIN_SALARIU_ASG_ITD
v_debit_curent = 0

if (REST_PLATA_1_ASG_MONTH < 0) then v_debit_curent = (-1) * REST_PLATA_1_ASG_MONTH

/* ---------------------------------------------------------------------------------------
cazul I: nu avem debit anterior si nici debit curent
--------------------------------------------------------------------------------------- */

if (REST_PLATA_1_ASG_MONTH >= 0) and (v_debit_anterior = 0) then


(
v_rest_plata_1 = REST_PLATA_1_ASG_MONTH

return v_rest_plata_1,
v_sting_debit /* Conta Stingere debit salariu */
)

/* ---------------------------------------------------------------------------------------
cazul II: avem debit anterior si nu avem debit curent
--------------------------------------------------------------------------------------- */

if (REST_PLATA_1_ASG_MONTH > 0) and (v_debit_anterior > 0) then


(
v_rest_plata_1 = REST_PLATA_1_ASG_MONTH
v_debit_retinere = least(v_rest_plata_1, v_debit_anterior)
v_debit_total = v_debit_anterior - v_debit_retinere
v_mesaj_1 = 'Atentie: ' + ELEMENT_NAME + ': avem debit anterior si nu avem debit curent '

return v_rest_plata_1,
v_debit_retinere, /* Debite din salariu retinere */
/* Conta Debite din salariu retinere */
v_debit_total, /* Debite din salariu */
v_mesaj_1,
v_sting_debit /* Conta Stingere debit salariu */
)

/* ---------------------------------------------------------------------------------------
cazul III: avem debit curent si nu avem debit anterior
--------------------------------------------------------------------------------------- */

if (REST_PLATA_1_ASG_MONTH < 0) and (v_debit_anterior = 0) then


(
v_rest_plata_1 = 0
v_debit_curent = (-1) * REST_PLATA_1_ASG_MONTH
v_debit_total = v_debit_curent
v_mesaj_1 = 'Atentie: ' + ELEMENT_NAME + ' : Avans neacoperit ' + to_text (v_debit_curent)

return v_rest_plata_1,
v_debit_curent, /* Debite din salariu */
/* Conta Debite din salarii*/
v_debit_total, /* Debite din salariu */
v_mesaj_1,
v_sting_debit /* Conta Stingere debit salariu */
)

/* ---------------------------------------------------------------------------------------
cazul IV: avem debit curent si avem debit anterior
--------------------------------------------------------------------------------------- */

if (REST_PLATA_1_ASG_MONTH < 0) and (v_debit_anterior > 0) then


(
v_rest_plata_1 = 0
v_debit_curent = (-1) * REST_PLATA_1_ASG_MONTH
v_debit_total = v_debit_anterior + v_debit_curent
v_mesaj_1 = 'Atentie: ' + ELEMENT_NAME + ' : Avans neacoperit ' + to_text (v_debit_curent)

return v_rest_plata_1,
v_debit_curent, /* Debite din salariu */
/* Conta Debite din salarii*/
v_debit_total, /* Debite din salariu */
v_mesaj_1,
v_sting_debit /* Conta Stingere debit salariu */
)

/* End: Formula: REST_PLATA_1 */

REST_PLATA_2
/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: REST_PLATA_2 */

default for REST_PLATA_2_ASG_MONTH is 0


default for CA_AGA_CENZ_ASG_MONTH is 0

v_rest_plata_2 = REST_PLATA_2_ASG_MONTH

/* ----------------
Conta
------------------- */
if (v_rest_plata_2 <> 0) then
if CA_AGA_CENZ_ASG_MONTH <> 0
then
/* Lichidare plata CA > Conta Virare indemnizatie CA neta in cont curent */
v_suma_ca = v_rest_plata_2
else
/* Lichidare plata>Conta Virare salarii nete in cont salariat */
v_suma = v_rest_plata_2
/* ----------------
End: Conta
------------------- */

return
v_rest_plata_2,

/* Lichidare plata>Conta Virare salarii nete in cont salariat */


v_suma,
/* Lichidare plata CA>Conta Virare indemnizatie CA neta in cont curent*/
v_suma_ca

/* End: Formula: REST_PLATA_2 */

RETINERE_AVANS

/********************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: RETINERE_AVANS */

default for SUMA is 0

default for POPRIRE_1_ASG_ITD is 0


default for POPRIRE_RETINERE_1_COUNT is 0

default for ELEMENT_NAME is ' '

inputs are SUMA

v_suma = SUMA

/* -----------------
Poprire
----------------- */
if ELEMENT_NAME = 'Poprire avans 1' and POPRIRE_RETINERE_1_COUNT = 0
then
(
v_m1 = ELEMENT_NAME + ': Nu exista elementul de retinere= ' + 'Poprire retinere 1'
v_suma = 0
)
Else
(
v_rest_plata = POPRIRE_1_ASG_ITD
v_suma = least(v_suma,v_rest_plata)
)
/* -----------------
End: Poprire
----------------- */

return
v_suma,
v_m1

/* End: Formula: RETINERE_AVANS */

RETINERI

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: RETINERI */

default for RETINERI_ASG_MONTH is 0

v_retineri = RETINERI_ASG_MONTH

return v_retineri
/* End: Formula: RETINERI */

SALARII

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: SALARII */

default for SALARII_ASG_MONTH is 0

v_salarii = SALARII_ASG_MONTH

if (v_salarii <> 0) then v_suma = v_salarii

return

v_salarii,

/* Conta Salarii */

v_suma

/* End: Formula: SALARII */

SALARIU_BAZA
/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SALARIU_BAZA

Versiunea de la NET la BRUT

Formula calculeaza:
1. Salariu lunar

Lista modificarilor:
Data versiuni: Autori: Observatii:
+-----------------+----------------------+----------------------------
23-SEP-2004 Oracle&Partener Versiuna originala
+--------------------------------------------------------------------+
*/

/* salary basis */
default for SALARIU is 0
default for ELEMENT_NAME is ' '
default for VENIT_BRUT_INFORMATIV_ASG_RUN is 0

/* norma intreaga { 8, 7, 6 } */
default for NORMA_INTREAGA_ASG_RUN is 8

/* Durata normala a timpului de lucru zilnic (durata muncii)


norma intreaga { 8, 7, 6 } / fractiune de norma { 7, 6, 5, 4, 3, 2 } */

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/

/* durata muncii standard */


default for DURATA_NORMALA_TIMP_LUCRU is 8

default for SALARIU_BAZA_ANTERIOR_REALIZAT_ASG_MONTH is 0


default for SALARIU_BAZA_ANTERIOR_ZILE_ASG_MONTH is 0
default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0

default for GRADE_GRILA_SALARIZARE_MAXIMUM is '0'

inputs are SALARIU


if SALARIU was defaulted then v_salariu = to_num(GRADE_GRILA_SALARIZARE_MAXIMUM)

v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */

v_durata_muncii = ASG_HOURS

if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part
if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU) then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

/* ------------------------------------------------------------------
salariul lunar
------------------------------------------------------------------ */

/* salariu pentru <Durata normala a timpului de lucru zilnic> */


v_salariu_baza_lunar = SALARIU
if SALARIU was defaulted then v_salariu_baza_lunar =
to_num(GRADE_GRILA_SALARIZARE_MAXIMUM)

if
/* negociere la Salariu net */
(VENIT_BRUT_INFORMATIV_ASG_RUN > 0) then
(v_salariu_baza_lunar = VENIT_BRUT_INFORMATIV_ASG_RUN
v_salariu = VENIT_BRUT_INFORMATIV_ASG_RUN)

if
/* salariu pentru <norma intreaga> */
GET_TABLE_VALUE('Salariu', 'Durata muncii', '1')='N' and
NORMA_INTREAGA_ASG_RUN <> 0 then
v_salariu_baza_lunar = round(SALARIU * (v_durata_muncii / NORMA_INTREAGA_ASG_RUN))

/* ------------------------------------------------------------------
End: salariul lunar
------------------------------------------------------------------ */

/* --------------------------
salariul anterior
----------------------------- */

Sa = SALARIU_BAZA_ANTERIOR_REALIZAT_ASG_MONTH
Z1 = SALARIU_BAZA_ANTERIOR_ZILE_ASG_MONTH
ZL = ZILE_LUCRATOARE_LUNA_ASG_RUN

if Sa > 0 and Z1 > 0 and ZL >0 then


(
v_salariu_baza_lunar = round(Sa + (ZL-Z1)/ZL * v_salariu_baza_lunar)
v_m1 = ELEMENT_NAME + ': Multiple Salary '
)
/* --------------------------
End: salariul anterior
----------------------------- */

v_lansare = ELEMENT_NAME

return
v_salariu,

/* salariul lunar */
v_salariu_baza_lunar,
v_lansare,

v_m1

/* End: Formula: SALARIU_BAZA */

SALARIU_BAZA_ANTERIOR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SALARIU_BAZA_ANTERIOR

Formula calculeaza:
1. Salariu lunar

Lista modificarilor:
Data versiuni: Autori: Observatii:
+-----------------+----------------------+----------------------------
23-SEP-2004 Oracle&Partener Versiuna originala
+--------------------------------------------------------------------+

*/

/* salary entry & proration */


default for SALARIU is 0
default for DATA_INCEPUT is '01-FEB-1900' (date)
default for DATA_SFARSIT is '01-FEB-4000' (date)

default for PAY_PROC_PERIOD_START_DATE IS '01-FEB-1950' (date)


default for PAY_PROC_PERIOD_END_DATE IS '01-FEB-1950' (date)

default for ELEMENT_NAME is ' '


default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0

inputs are
SALARIU (number) ,
DATA_INCEPUT (date),
DATA_SFARSIT (date)

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/* --------------------------------------------------------------------------------------
Perioada anterioara
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest(DATA_INCEPUT, PAY_PROC_PERIOD_START_DATE)

v_data_sfarsit = least(DATA_SFARSIT, PAY_PROC_PERIOD_END_DATE)

/* zile lucratoare cu Salariu [nr] */


v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)
/* corectie nr de zile
---------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------*/
v_zile = v_z

/* ---------------------------------------------------------------------------------------
End: Perioada anterioara
---------------------------------------------------------------------------------------- */

/* ----------------------------------------------------------------------------------
Salariu baza lunar [nr]
Z1/ZL * S1 + Z2/ZL * S2 + ?
Z1/ZL * Si + Z2/ZL * Sm
Z1/ZL * Sa + (ZL-Z1)/ZL * Sm
1. se modifica cu update salariu baza (Sm) cu data de x
2. se introduce elementul
Salariu baza anterior (Sa)
-salariu
-data inceput=1
-data sfarsit=x-1
-zile
-salariu realizat
----------------------------------------------------------------------------------- */

v_coef = v_zile / ZILE_LUCRATOARE_LUNA_ASG_RUN

v_salariu_realizat = Salariu * v_coef

/* ----------------------------------------------------------------------------------
End: Salariu baza lunar [nr] realizat
----------------------------------------------------------------------------------- */

v_m1 = ELEMENT_NAME
+ ' Salariu = ' + to_char(Salariu)
+ ' Z = ' + to_char(v_zile) + ' ZL = ' + to_char(ZILE_LUCRATOARE_LUNA_ASG_RUN)
+ ' Coef = ' + to_char(v_coef)

return
v_zile,
v_salariu_realizat,

v_m1

/* End: Formula: SALARIU_BAZA_ANTERIOR */

SALARIU_BAZA_ORAR

/******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SALARIU_BAZA_ORAR

Formula calculeaza:
1. Salariu orar

Lista modificarilor:
Data versiuni: Autori: Observatii:
+-----------------+----------------------+----------------------------
23-SEP-2004 Oracle Versiuna originala
+--------------------------------------------------------------------+
*/

default for SALARIU_BAZA_LUNAR_ASG_RUN is 0


default for MOD_ANGAJARE_FORMA_ORGANIZARE_MUNCA_ENTRY_VALUE is '1'
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 1
default for NR_MEDIU_ORE_LUCRATOARE_LUNA is 1
default for ELEMENT_NAME is ' '

v_o_lucratoare = ORE_LUCRATOARE_LUNA_ASG_RUN
if v_o_lucratoare = 0 then
(
v_m1 = ELEMENT_NAME + ': Ore lucratoare luna=' + to_text(ORE_LUCRATOARE_LUNA_ASG_RUN)
return v_m1
)

/* salariul lunar */
v_salariu_baza_lunar = SALARIU_BAZA_LUNAR_ASG_RUN
/* End: salariul lunar */

/* salariul orar */

/* Dupa timp_cu salariul negociat orar */


if (MOD_ANGAJARE_FORMA_ORGANIZARE_MUNCA_ENTRY_VALUE = '2') then
v_salariu_baza_orar =
(round(v_salariu_baza_lunar / NR_MEDIU_ORE_LUCRATOARE_LUNA *100 / 5, 0) * 5 ) / 100

/* In regie_cu salariul negociat lunar */


if (MOD_ANGAJARE_FORMA_ORGANIZARE_MUNCA_ENTRY_VALUE = '1') then
v_salariu_baza_orar =
round(v_salariu_baza_lunar / v_o_lucratoare, 7)

/* End: salariul orar */

return
v_salariu_baza_orar

/* End: Formula: SALARIU_BAZA_ORAR */

SALARIU_BAZA_REALIZAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SALARIU_BAZA_REALIZAT */

default for SALARIU_BAZA_ORAR_ASG_RUN is 0


default for SALARIU_BAZA_LUNAR_ASG_RUN is 0

default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0

default for ORE_LUCRATE_LUNA_ASG_RUN is 0


default for ZILE_LUCRATE_LUNA_ASG_RUN is 0
default for ROT is 0
default for PROCENT_CN_ASG_MONTH is 0
default for PROCENT_CD_ASG_MONTH is 0
default for PROCENT_CS_ASG_MONTH is 0
default for ORE_CN_ASG_RUN is 0
default for ORE_CD_ASG_RUN is 0
default for ORE_CS_ASG_RUN is 0
/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3

/* -------------------------------
Salariu realizat
------------------------------- */

v_ore = ORE_LUCRATE_LUNA_ASG_RUN
v_zile = ZILE_LUCRATE_LUNA_ASG_RUN
v_salariu_orar = SALARIU_BAZA_ORAR_ASG_RUN

if (ZILE_LUCRATE_LUNA_ASG_RUN = ZILE_LUCRATOARE_LUNA_ASG_RUN)
then
v_salariu_realizat = SALARIU_BAZA_LUNAR_ASG_RUN
else
v_salariu_realizat = round(v_ore * v_salariu_orar, ROT)

/* -------------------------------
End:Salariu realizat
------------------------------- */

/* -------------------------------
Conditii de munca
------------------------------- */
baza = v_salariu_realizat

if v_cond_m = 1 then v_cs = baza


if v_cond_m = 2 then v_cd = baza
if v_cond_m = 3 then v_cn = baza
baza = v_salariu_realizat

/* -----------------------------------
EXCEPTIE
-------------------------------------- */
if ORE_CN_ASG_RUN <> 0
then
(
v_cd = round(baza * PROCENT_CD_ASG_MONTH / 100, ROT)
v_cs = round(baza * PROCENT_CS_ASG_MONTH / 100, ROT)
v_cn = baza - (v_cd + v_cs)
)
else if ORE_CD_ASG_RUN <> 0 then
(
v_cs = round(baza * PROCENT_CS_ASG_MONTH / 100, ROT)
v_cd = baza - (v_cs)
)
else if ORE_CS_ASG_RUN <> 0 then
(
v_cs = round(baza * PROCENT_CS_ASG_MONTH / 100, ROT)
)
/* ---------------------------------------
EXCEPTIE
------------------------------------------ */

/* -------------------------------
End: Conditii de munca
------------------------------- */

return
v_salariu_realizat,
v_ore,
v_zile,
v_cn,
v_cd,
v_cs

/* End: Formula: SALARIU_BAZA_REALIZAT */

SALARIU_NET

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: SALARIU_NET */

default for SALARIU_NET_ASG_MONTH is 0

/* actualizare pentru luna urmatoare (update recuring)

Salariu Net Istoric

Salariu Net Istoric se calculeaza


Salariu Net Istoric 2 in Salariu Net Istoric 1, etc

*/

/* luna curenta: SALARIU_NET_ASG_MONTH */

default for SALARIU_NET_1_ASG_RUN is 0

default for SALARIU_NET_2_ASG_RUN is 0

default for SALARIU_NET_3_ASG_RUN is 0

default for SALARIU_NET_4_ASG_RUN is 0

default for SALARIU_NET_5_ASG_RUN is 0

default for SALARIU_NET_6_ASG_RUN is 0

default for SALARIU_NET_7_ASG_RUN is 0

default for SALARIU_NET_8_ASG_RUN is 0

default for SALARIU_NET_9_ASG_RUN is 0

default for SALARIU_NET_10_ASG_RUN is 0

default for SALARIU_NET_11_ASG_RUN is 0

/* End: actualizare pentru luna urmatoare Salariu Net Istoric */

/* salariu net */

v_salariu_net = SALARIU_NET_ASG_MONTH

/* actualizare pentru luna urmatoare Salariu Net Istoric */

v_net_1 = SALARIU_NET_ASG_MONTH

v_net_2 = SALARIU_NET_1_ASG_RUN

v_net_3 = SALARIU_NET_2_ASG_RUN
v_net_4 = SALARIU_NET_3_ASG_RUN

v_net_5 = SALARIU_NET_4_ASG_RUN

v_net_6 = SALARIU_NET_5_ASG_RUN

v_net_7 = SALARIU_NET_6_ASG_RUN

v_net_8 = SALARIU_NET_7_ASG_RUN

v_net_9 = SALARIU_NET_8_ASG_RUN

v_net_10 = SALARIU_NET_9_ASG_RUN

v_net_11 = SALARIU_NET_10_ASG_RUN

v_net_12 = SALARIU_NET_11_ASG_RUN

/* End: actualizare pentru luna urmatoare Salariu Net Istoric */

return

/* salariu net */

v_salariu_net,

/* actualizare pentru luna urmatoare Salariu Net Istoric */

v_net_1,

v_net_2,

v_net_3,

v_net_4,

v_net_5,

v_net_6,

v_net_7,

v_net_8,

v_net_9,

v_net_10,

v_net_11,
v_net_12

/* End: Formula: SALARIU_NET */

SALARIU_NET_TOTAL

/* *******************************************************************

* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: SALARIU_NET_TOTAL */

default for SALARIU_NET_TOTAL_ASG_MONTH is 0

v_sal_net_total = SALARIU_NET_TOTAL_ASG_MONTH

return v_sal_net_total

/* End: Formula: SALARIU_NET_TOTAL */

SANATATE_ANGAJAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SANATATE_ANGAJAT */
/* Sanatate angajat */
default for Baza is 0
/* Globals */
default for SANATATE_ASIGURAT is 0
/*
Invalid gr 1
Invalid gr 2
*/
default for PER_DISABLED is ' '
default for CA_AGA_CENZ_ASG_MONTH is 0

inputs are
Baza

/* -------------------------------------------------------------------------
Baza Sanatate angajat
------------------------------------------------------------------------- */

v_baza_calcul_san = Baza
if
/* English version */
(PER_DISABLED = 'Yes - Partially Disabled') or
/* Romanian version */
(PER_DISABLED = 'Da - Cu incapacitate parial') then
v_baza_calcul_san = 0

if
/* English version */
(PER_DISABLED = 'Yes - Fully Disabled') or
/* Romanian version */
(PER_DISABLED = 'Da - Cu incapacitate total') then
v_baza_calcul_san = 0

/* -------------------------------------------------------------------------
End: Baza Sanatate angajat
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Sanatate angajat
------------------------------------------------------------------------- */

v_sanatate_angajat = round((SANATATE_ASIGURAT / 100) * v_baza_calcul_san)

/* -------------------------------------------------------------------------
End: Sanatate angajat
------------------------------------------------------------------------- */

/* ----------------
Conta
------------------- */
if (v_sanatate_angajat <> 0) then
if CA_AGA_CENZ_ASG_MONTH <> 0
then
/* Conta Sanatate CA */
v_suma_ca = v_sanatate_angajat
else
/* Conta Sanatate angajat */
v_suma = v_sanatate_angajat
/* ----------------
End: Conta
------------------- */

return
v_sanatate_angajat, /* PV */
v_baza_calcul_san,

/* Conta Sanatate angajat */


v_suma,
/* Conta Sanatate CA */
v_suma_ca

/* End: Formula: SANATATE_ANGAJAT */

SANATATE_ANGAJATOR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SANATATE_ANGAJATOR v1 jan 06 */

default for SANATATE_ANGAJATOR is 0 /* 7 */


default for BAZA_SANATATE_ANGAJAT_ASG_MONTH is 0
default for PROFIT_ASG_MONTH is 0
default for TOTAL_PRESTATII_INTR_ASG_MONTH is 0
default for PRIMA_PROFIT_ASG_MONTH is 0
default for CONTARE_SEPARATA_PROFIT_SANATATE_ANGAJATOR is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)
default for FACILITATI_SUPUSE_IMPOZITARII_ASG_MONTH is 0
/*default for CA_AGA_CENZ_ASG_MONTH is 0*/

/* -------------------------------------------------------------------------
Baza Sanatate angajator
------------------------------------------------------------------------- */
/*
fond de salarii realizat =
drepturi salariale si / sau drepturi asimilate salariilor

drepturi asimilate salariilor =


a) Avantaje in bani si in natura [art. 56 (2) din Codul Fiscal ]
*/
v_baza_calcul_san =
BAZA_SANATATE_ANGAJAT_ASG_MONTH +
FACILITATI_SUPUSE_IMPOZITARII_ASG_MONTH+
TOTAL_PRESTATII_INTR_ASG_MONTH -
PROFIT_ASG_MONTH /* + CORECTII_PANA_LA_BRUT_6_SUME_BOALA_FOND_SALARII */
/*- CA_AGA_CENZ_ASG_MONTH*/
/* -------------------------------------------------------------------------
End: Baza Sanatate angajator
------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------
Sanatate angajator
------------------------------------------------------------------------- */
if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_sanatate_angajator = round((SANATATE_ANGAJATOR / 100) * v_baza_calcul_san, 4)
else
v_sanatate_angajator = round((SANATATE_ANGAJATOR / 100) * v_baza_calcul_san, 2)
/* -------------------------------------------------------------------------
End: Sanatate angajator
------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
Conta
------------------------------------------------------------------------- */
v_sanatate_prima = 0
if
/* Contare separata contributii angajator pentru Profit */
(CONTARE_SEPARATA_PROFIT_SOMAJ_ANGAJATOR = 'Y') then
( /* N 1 */

v_prima = PRIMA_PROFIT_ASG_MONTH

/* Conta Prima profit Sanatate angajator


--------------------------------------------- */
v_sanatate_prima = round((SANATATE_ANGAJATOR / 100) * v_prima)

) /* N 1 */

/* Conta Sanatate angajator */


v_suma_sanatate = v_sanatate_angajator - v_sanatate_prima

/* -------------------------------------------------------------------------
End: Conta
------------------------------------------------------------------------- */

return
v_baza_calcul_san,
v_sanatate_angajator,

/* Conta Sanatate angajator */


v_suma_sanatate

/* End: Formula: SANATATE_ANGAJATOR */


SOMAJ_ANGAJATOR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SOMAJ_ANGAJATOR vs. 1 jan 06*/

default for PROCENT_SOMAJ_ANGAJATOR is 0 /* 2.5 */


default for TOTAL_BRUT_ASG_MONTH is 0
default for TOTAL_PRESTATII_CAS_ASG_MONTH is 0
default for MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE is ' '
default for MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE is '01-FEB-1900' (date)
default for PER_DISABLED is ' '
default for EMP_HIRE_DATE is '01-FEB-2003' (date)
default for EMP_TERM_DATE is '01-FEB-2203' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-2003' (date)
default for PRIMA_PROFIT_ASG_MONTH is 0
default for PROFIT_ASG_MONTH is 0
default for CONTARE_SEPARATA_PROFIT_SOMAJ_ANGAJATOR is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-2003' (date)
default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0

v_z_lucratoare_luna = ZILE_LUCRATOARE_LUNA_ASG_RUN

/* ------------------------------------------------------------------
Lg.76/2002 art.80 >> absolventi de invatamant
------------------------------------------------------------------ */
v_absolvent = 'N'
v_z_scutire_luna = 0

/* absolvent al ciclului inferior al liceului sau al scolilor de arte si meserii */


if (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = '2' ) then
(v_nr_salarii = 1
v_absolvent = 'Y')

/* absolvent de invatamant secundar superior sau invatamant postliceal */


if (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = '3' ) then
(v_nr_salarii = 1.2
v_absolvent = 'Y')

/* absolvent de invatamant superior */


if (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = '4' ) then
(v_nr_salarii = 1.5
v_absolvent = 'Y')

if (v_absolvent = 'Y') then


( /* N 1 */
v_nr_luni = 12

if
/* English version */
(substr(PER_DISABLED,1,1) = 'Y') or
/* Romanian version */
(substr(PER_DISABLED,1,1) = 'D') then v_nr_luni = 18

/* --------------------------------------------------------------------------------------
Perioada scutire
---------------------------------------------------------------------------------------*/
LC_EX_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
LC_EX_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
LC_EX_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
LC_EX_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
LC_EX_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
LC_EX_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
LC_EX_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

LB_EX_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


LB_EX_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
LB_EX_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
LB_EX_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
LB_EX_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

v_data_angajarii = MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_ANGAJARII_IN_UNITATE_ENTRY_VALUE was defaulted)
then
v_data_angajarii = EMP_HIRE_DATE

v_data_terminarii = MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE
if (MOD_ANGAJARE_DATA_PLECARII_DIN_UNITATE_ENTRY_VALUE was defaulted)
then
v_data_terminarii = EMP_TERM_DATE

v_d_term_perioada = ADD_MONTHS(v_data_angajarii, v_nr_luni)

v_data_inceput = greatest(v_data_angajarii, PAY_PROC_PERIOD_START_DATE)

v_data_sfarsit = least(v_data_terminarii, v_d_term_perioada, PAY_PROC_PERIOD_END_DATE)

v_z_scutire_luna = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)


/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_z_scutire_luna /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (LC_EX_1 >= v_d_i and LC_EX_1 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_2 >= v_d_i and LC_EX_2 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_3 >= v_d_i and LC_EX_3 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_4 >= v_d_i and LC_EX_4 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_5 >= v_d_i and LC_EX_5 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_6 >= v_d_i and LC_EX_6 <= v_d_s) Then v_z = v_z - 1
if (LC_EX_7 >= v_d_i and LC_EX_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (LB_EX_1 >= v_d_i and LB_EX_1 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_2 >= v_d_i and LB_EX_2 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_3 >= v_d_i and LB_EX_3 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_4 >= v_d_i and LB_EX_4 <= v_d_s) Then v_z = v_z + 1
if (LB_EX_5 >= v_d_i and LB_EX_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
-------------------------------*/
v_z_scutire_luna = v_z

/* ---------------------------------------------------------------------------------------
End: Perioada scutire
---------------------------------------------------------------------------------------- */
) /* N 1 */

/* ------------------------------------------------------------------
End: Lg.76/2002 art.80 >> absolventi de invatamant
------------------------------------------------------------------ */

/* ------------------------------------------------------------------
Baza calcul
------------------------------------------------------------------ */
v_baza_calcul = TOTAL_BRUT_ASG_MONTH - TOTAL_PRESTATII_CAS_ASG_MONTH -
PROFIT_ASG_MONTH

/* absolvent de invatamant */
if (v_absolvent = 'Y') then
(
if (v_z_lucratoare_luna <> 0) then
v_baza_calcul = v_baza_calcul - (v_baza_calcul / v_z_lucratoare_luna * v_z_scutire_luna)
)

/* salariat pensionar pe limita de varsta */


if (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'P' ) then v_baza_calcul = 0
if
/* salariat pensionar pe limita de varsta */
MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'P'
/* salariat cetatean strain */
or MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'R'
or MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'N'
then v_baza_calcul = 0

/* ------------------------------------------------------------------
End: Baza calcul
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
Contributie
------------------------------------------------------------------ */
if (PAY_PROC_PERIOD_START_DATE < to_date('01/07/2005','DD/MM/YYYY') )
then
v_somaj_angajator = round((PROCENT_SOMAJ_ANGAJATOR / 100) * v_baza_calcul, 4)
else
v_somaj_angajator = round((PROCENT_SOMAJ_ANGAJATOR / 100) * v_baza_calcul, 2)
/* ------------------------------------------------------------------
End: Contributie
------------------------------------------------------------------ */
/* ------------------------------------------------------------------
Deduceri si Reduceri
------------------------------------------------------------------ */
v_DED80REC = 0 /* SUB80REC */
v_DED80RES = 0 /* SUB80RES */
v_DED85REC = 0 /* SUB85REC */
v_DED85RES = 0 /* SUB85RES */
v_DED58REC = 0 /* SC80144REC */
v_DED58RES = 0 /* SC80144RES */
v_DED116REC = 0 /* SC85144REC */
v_DED116RES = 0 /* SC85144RES */
v_RED9394REC = 0
v_RED9394RES = 0

/* somaj angajator continuare */


v_SUB58REC = 0
v_SUB58RES = 0
v_SUB116REC = 0
v_SUB116RES = 0
v_SUB17AREC = 0
v_SUB17ARES = 0
v_SUB17BREC = 0
v_SUB17BRES = 0

/* Lg.76/2002 art.80 >> deduceri pentru absolventi de invatamant


----------------------------------------------------------------------------- */
/* absolvent de invatamant */
if (v_absolvent = 'Y') then
(
v_DED80REC = 0
eff_date = PAY_PROC_PERIOD_START_DATE
SMIN = to_number(GET_TABLE_VALUE('Sal min economie', 'Valoare', '1', eff_date))

if (v_z_lucratoare_luna <> 0) then


v_DED80REC = round(v_nr_salarii * SMIN / v_z_lucratoare_luna * v_z_scutire_luna)
)
/* End: Lg.76/2002 art.80 >> deduceri pentru absolventi de invatamant
---------------------------------------------------------------------------------- */

/* ------------------------------------------------------------------
End: Deduceri si Reduceri
------------------------------------------------------------------ */

/* -------------------------------------------------------------------------
Conta
------------------------------------------------------------------------- */
v_somaj_prima = 0
if
/* Contare separata contributii angajator pentru Profit */
(CONTARE_SEPARATA_PROFIT_SOMAJ_ANGAJATOR = 'Y') then
( /* N 1 */

v_prima = PRIMA_PROFIT_ASG_MONTH

/* Conta Prima profit Somaj angajator


------------------------------------------- */
v_baza_prima = v_prima
/* salariat pensionar pe limita de varsta */
if (MOD_ANGAJARE_VINE_DIN_ENTRY_VALUE = 'P' ) then v_baza_prima = 0

v_somaj_prima = round((PROCENT_SOMAJ_ANGAJATOR / 100) * v_baza_prima)

) /* N 1 */

/* Conta somaj angajator */


v_suma_somaj = v_somaj_angajator - v_somaj_prima

/* -------------------------------------------------------------------------
End: Conta
------------------------------------------------------------------------- */

return
v_baza_calcul,
v_somaj_angajator,

v_DED80REC,
v_DED80RES,
v_DED85REC,
v_DED85RES,
v_DED58REC,
v_DED58RES,
v_DED116REC,
v_DED116RES,
v_RED9394REC,
v_RED9394RES,

/* somaj angajator continuare */


v_SUB58REC,
v_SUB58RES,
v_SUB116REC,
v_SUB116RES,
v_SUB17AREC,
v_SUB17ARES,
v_SUB17BREC,
v_SUB17BRES,

/* Conta somaj_angajator */
v_suma_somaj

/* End: Formula: SOMAJ_ANGAJATOR */

SOMAJ_ANGAJAT_CORECTII

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *
* All rights reserved. *

* *

******************************************************************/

/* Formula: SOMAJ_ANGAJAT_CORECTII */

default for SUMA is 0

inputs are SUMA

return

SUMA /* Conta Somaj angajat */

/* End: Formula: SOMAJ_ANGAJAT_CORECTII */

SPOR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPOR

Formula calculeaza:
1. Sume sporuri

Lista modificarilor:
Data versiuni: Autori: Observatii:
+-----------------+----------------------+----------------------------
05-NOV-2004 Oracle&Partener Versiuna originala
+--------------------------------------------------------------------+

*/

/* Spor */
default for Ore is 0
default for Procent is 0
/* End: Spor */
default for SALARIU_BAZA_ORAR_ASG_RUN is 0
default for ROT is 0
default for PROCENT_CN_ASG_MONTH is 0
default for PROCENT_CD_ASG_MONTH is 0
default for PROCENT_CS_ASG_MONTH is 0
default for ORE_CN_ASG_MONTH is 0
default for ORE_CD_ASG_MONTH is 0
default for ORE_CS_ASG_MONTH is 0
/* pre-configurat 3 = CN */
default for CONDITII_DE_MUNCA_ASG_MONTH is 0
default for ELEMENT_NAME is ' '

default for TIMP_L_SAMB_ASG_MONTH is 0


default for TIMP_L_DUM_ASG_MONTH is 0
default for TIMP_L_SARB_ASG_MONTH is 0
default for TIMP_L_SUPL_ASG_MONTH is 0
default for TIMP_L_NOAPTE_ASG_MONTH is 0

default for TIMP_L_SAMB_CD_ASG_MONTH is 0


default for TIMP_L_DUM_CD_ASG_MONTH is 0
default for TIMP_L_SARB_CD_ASG_MONTH is 0
default for TIMP_L_SUPL_CD_ASG_MONTH is 0
default for TIMP_L_NOAPTE_CD_ASG_MONTH is 0

inputs are
Ore,
Procent

v_cond_m = CONDITII_DE_MUNCA_ASG_MONTH
if CONDITII_DE_MUNCA_ASG_MONTH = 0 then v_cond_m = 3

v_spor = round(Procent / 100 * SALARIU_BAZA_ORAR_ASG_RUN * Ore, ROT)

if
ELEMENT_NAME = 'Spor Conducere' or
ELEMENT_NAME = 'Spor Functie Suplimentara' or
ELEMENT_NAME = 'Spor Sistematic' or
ELEMENT_NAME = 'Spor Limba Straina' or
ELEMENT_NAME = 'Spor Tractare' or
ELEMENT_NAME = 'Spor Gestiune' or
ELEMENT_NAME = 'Spor Titlu Stiintific' or
ELEMENT_NAME = 'Spor Sef Echipa' or
ELEMENT_NAME = 'Spor Fidelitate' or
ELEMENT_NAME = 'Spor Vechime' then
( /* N1 */
procent_cd = PROCENT_CD_ASG_MONTH
procent_cs = PROCENT_CS_ASG_MONTH
) /* N1 */

if
ELEMENT_NAME = 'Spor Sambata' then
( /* N1 */
procent_cd = 0
if TIMP_L_SAMB_ASG_MONTH <> 0 then
procent_cd = TIMP_L_SAMB_CD_ASG_MONTH / TIMP_L_SAMB_ASG_MONTH * 100
procent_cs = 0
) /* N1 */

if
ELEMENT_NAME = 'Spor Duminica' then
( /* N1 */
procent_cd = 0
if TIMP_L_DUM_ASG_MONTH <> 0 then
procent_cd = TIMP_L_DUM_CD_ASG_MONTH / TIMP_L_DUM_ASG_MONTH * 100
procent_cs = 0
) /* N1 */

if
ELEMENT_NAME = 'Spor Noapte' then
( /* N1 */
procent_cd = 0
if TIMP_L_NOAPTE_ASG_MONTH <> 0 then
procent_cd = TIMP_L_NOAPTE_CD_ASG_MONTH / TIMP_L_NOAPTE_ASG_MONTH * 100
procent_cs = 0
) /* N1 */

if
ELEMENT_NAME = 'Spor Ore Suplimentare' then
( /* N1 */
procent_cd = 0
if TIMP_L_SUPL_ASG_MONTH <> 0 then
procent_cd = TIMP_L_SUPL_CD_ASG_MONTH / TIMP_L_SUPL_ASG_MONTH * 100
procent_cs = 0
) /* N1 */

if
ELEMENT_NAME = 'Spor Sarbatori' then
( /* N1 */
procent_cd = 0
if TIMP_L_SARB_ASG_MONTH <> 0 then
procent_cd = TIMP_L_SARB_CD_ASG_MONTH / TIMP_L_SARB_ASG_MONTH * 100
procent_cs = 0
) /* N1 */

/* -------------------------------
Conditii de munca
------------------------------- */
baza = v_spor

if v_cond_m = 1 then v_cs = baza


if v_cond_m = 2 then v_cd = baza
if v_cond_m = 3 then v_cn = baza

if ORE_CN_ASG_MONTH <> 0
then
(
v_cd = round(baza * procent_cd / 100, ROT)
v_cs = round(baza * procent_cs / 100, ROT)
v_cn = baza - (v_cd + v_cs)
)
else if ORE_CD_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
v_cd = baza - (v_cs)
)
else if ORE_CS_ASG_MONTH <> 0 then
(
v_cs = round(baza * procent_cs / 100, ROT)
)
/* -------------------------------
End: Conditii de munca
------------------------------- */

return
v_spor,

v_cn,
v_cd,
v_cs

/* End: Formula: SPOR */

SPORT_1

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPORT_1 */

default for REST_PLATA_2_ASG_MONTH is 0


default for ELEMENT_NAME is ' '
default for RATA is 0
default for SPORT_1_NEACOPERIT_ASG_ITD is 0

inputs are RATA

v_disponibil = REST_PLATA_2_ASG_MONTH
v_rata = RATA
v_neacoperit_initial = SPORT_1_NEACOPERIT_ASG_ITD

v_rata_de_platit = (v_rata + v_neacoperit_initial)

v_rata_retinuta = least(v_disponibil,v_rata_de_platit)

v_neacoperit_final = v_rata_de_platit - v_rata_retinuta


if (v_neacoperit_final > 0) then
v_mesaj_1 = ELEMENT_NAME + ' : Retinere neacoperita = ' + to_text(v_neacoperit_final)

return
v_neacoperit_initial,
v_neacoperit_final,
v_mesaj_1,
v_rata_retinuta

/* End: Formula: SPORT_1 */

SPORURI

/* *******************************************************************

* *

* Copyright (C) 2004 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: SPORURI */

default for SPORURI_ASG_MONTH is 0

v_total_sporuri = SPORURI_ASG_MONTH

if (v_total_sporuri <> 0) then v_suma = v_total_sporuri

return

v_total_sporuri,

/* Conta sporuri */

v_suma

/* End: Formula: SPORURI */


SPORURI_NEGOCIATE

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPORURI_NEGOCIATE */

/* Sporuri negociate */
default for VECHIME is '0'
default for FIDELITATE is '0'
default for Functie_suplimentara is 0
default for SISTEMATIC is '0'
default for LIMBA_STRAINA is '0'
default for Tractare is '0'
default for Gestiune is '0'
default for Sef_echipa is '0'
default for SP_CONDUCERE is '0'
default for Titlu_stiintific is '0'
default for INDEMNIZ_CONDUCERE is 0
/* End: Sporuri negociate */

default for JOB_KF_SPOR_FUNCTIE_SUPLIMENTARA is '-77'


default for JOB_KF_SPOR_SISTEMATIC is '-77'
default for JOB_KF_SPOR_LIMBA_STRAINA is '-77'
default for JOB_KF_SPOR_TRACTARE is '-77'
default for JOB_KF_SPOR_GESTIUNE is '-77'
default for JOB_KF_SPOR_SEF_ECHIPA is '-77'
default for JOB_KF_SPOR_CONDUCERE is '-77'
default for JOB_KF_INDEMNIZ_CONDUCERE is '-77'

default for PAY_PROC_PERIOD_END_DATE IS '01-FEB-1900' (DATE)


default for VECHIME_MUNCA_ANI_ASG_RUN is 0
default for JOB_KF_TRANSA_DE_VECHIME is '0'
default for VECHIME_NEINTRERUPTA_ANI_ASG_RUN is 0
default for VECHIME_NEINTRERUPTA is 'N'

inputs are
VECHIME,
FIDELITATE,
Functie_suplimentara,
SISTEMATIC,
LIMBA_STRAINA,
Tractare,
Gestiune,
Sef_echipa,
SP_CONDUCERE,
Titlu_stiintific,
INDEMNIZ_CONDUCERE
/* -------------------------------------------------------------------------
Procent spor
------------------------------------------------------------------------- */

/* are negociat */

/* -----------------------------------------
Sporul de vechime in munca
------------------------------------------ */
if (Vechime was not defaulted)
then v_pr_vechime=to_num(Vechime)
else ( /* N 1 */
v_tr = to_num(JOB_KF_TRANSA_DE_VECHIME)
v_vech = VECHIME_MUNCA_ANI_ASG_RUN
eff_date = PAY_PROC_PERIOD_END_DATE

if v_tr = 1 then
(
if v_vech > TO_NUM(GET_TABLE_VALUE('Vechime Transa 1', 'An', '6', eff_date))
then v_pr = GET_TABLE_VALUE('Vechime Transa 1', 'Procent', '6', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 1', 'An', '5', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 1', 'Procent', '5', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 1', 'An', '4', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 1', 'Procent', '4', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 1', 'An', '3', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 1', 'Procent', '3', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 1', 'An', '2', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 1', 'Procent', '2', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 1', 'An', '1', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 1', 'Procent', '1', eff_date) else
v_pr = '0'
)

if v_tr = 2 then
(
if v_vech > TO_NUM(GET_TABLE_VALUE('Vechime Transa 2', 'An', '6', eff_date))
then v_pr = GET_TABLE_VALUE('Vechime Transa 2', 'Procent', '6', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 2', 'An', '5', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 2', 'Procent', '5', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 2', 'An', '4', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 2', 'Procent', '4', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 2', 'An', '3', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 2', 'Procent', '3', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 2', 'An', '2', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 2', 'Procent', '2', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 2', 'An', '1', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 2', 'Procent', '1', eff_date) else
v_pr = '0'
)

if v_tr = 3 then
(
if v_vech > TO_NUM(GET_TABLE_VALUE('Vechime Transa 3', 'An', '6', eff_date))
then v_pr = GET_TABLE_VALUE('Vechime Transa 3', 'Procent', '6', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 3', 'An', '5', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 3', 'Procent', '5', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 3', 'An', '4', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 3', 'Procent', '4', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 3', 'An', '3', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 3', 'Procent', '3', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 3', 'An', '2', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 3', 'Procent', '2', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Vechime Transa 3', 'An', '1', eff_date))


then v_pr = GET_TABLE_VALUE('Vechime Transa 3', 'Procent', '1', eff_date) else
v_pr = '0'
)
if to_num(v_pr) > 0 then v_pr_vechime = to_num(v_pr)
) /* N 1 */
/* -----------------------------------------
End: Sporul de vechime in munca
----------------------------------------- */

/* -----------------------------------------
spor de fidelitate
----------------------------------------- */
if (FIDELITATE was not defaulted)
then v_pr_FIDELITATE=to_num(FIDELITATE)
else ( /* N 1 */
v_vech = VECHIME_MUNCA_ANI_ASG_RUN
if VECHIME_NEINTRERUPTA = 'D' or
VECHIME_NEINTRERUPTA_ANI_ASG_RUN <> 0 then
v_vech = VECHIME_NEINTRERUPTA_ANI_ASG_RUN
eff_date = PAY_PROC_PERIOD_END_DATE

if v_vech >= TO_NUM(GET_TABLE_VALUE('Fidelitate Transa', 'An', '5', eff_date))


then v_pr = GET_TABLE_VALUE('Fidelitate Transa', 'Procent', '5', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Fidelitate Transa', 'An', '4', eff_date))


then v_pr = GET_TABLE_VALUE('Fidelitate Transa', 'Procent', '4', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Fidelitate Transa', 'An', '3', eff_date))


then v_pr = GET_TABLE_VALUE('Fidelitate Transa', 'Procent', '3', eff_date) else

if v_vech >= TO_NUM(GET_TABLE_VALUE('Fidelitate Transa', 'An', '2', eff_date))


then v_pr = GET_TABLE_VALUE('Fidelitate Transa', 'Procent', '2', eff_date) else
if v_vech >= TO_NUM(GET_TABLE_VALUE('Fidelitate Transa', 'An', '1', eff_date))
then v_pr = GET_TABLE_VALUE('Fidelitate Transa', 'Procent', '1', eff_date) else
v_pr = '0'

if to_num(v_pr) > 0 then v_pr_FIDELITATE = to_num(v_pr)


) /* N 1 */
/* -----------------------------------------
End: spor de fidelitate
----------------------------------------- */

if (JOB_KF_SPOR_FUNCTIE_SUPLIMENTARA <> '-77') then


v_id_FUNCTIE_SUPLIMENTARA= to_num(JOB_KF_SPOR_FUNCTIE_SUPLIMENTARA)
if (FUNCTIE_SUPLIMENTARA was not defaulted) then
v_id_FUNCTIE_SUPLIMENTARA= FUNCTIE_SUPLIMENTARA

if (JOB_KF_SPOR_SISTEMATIC <> '-77') then


v_pr_SISTEMATIC=to_num(JOB_KF_SPOR_SISTEMATIC)
if (SISTEMATIC was not defaulted) then v_pr_SISTEMATIC = to_num(SISTEMATIC)

if (JOB_KF_SPOR_LIMBA_STRAINA <> '-77') then


v_pr_LIMBA_STRAINA =to_num(JOB_KF_SPOR_LIMBA_STRAINA)
if (LIMBA_STRAINA was not defaulted) then v_pr_LIMBA_STRAINA =to_num(LIMBA_STRAINA)

if (JOB_KF_SPOR_TRACTARE <> '-77') then v_pr_TRACTARE =to_num(JOB_KF_SPOR_TRACTARE)


if (TRACTARE was not defaulted) then v_pr_TRACTARE= to_num(TRACTARE)

if (JOB_KF_SPOR_GESTIUNE <> '-77') then v_pr_GESTIUNE =to_num(JOB_KF_SPOR_GESTIUNE)


if (GESTIUNE was not defaulted) then v_pr_GESTIUNE=to_num(GESTIUNE)

if (JOB_KF_SPOR_SEF_ECHIPA <> '-77') then v_pr_SEF_ECHIPA


=to_num(JOB_KF_SPOR_SEF_ECHIPA)
if (SEF_ECHIPA was not defaulted) then v_pr_SEF_ECHIPA=to_num(SEF_ECHIPA)

if (JOB_KF_SPOR_CONDUCERE <> '-77') then v_pr_CONDUCERE


=to_num(JOB_KF_SPOR_CONDUCERE)
if (SP_CONDUCERE was not defaulted) then v_pr_CONDUCERE=to_num(SP_CONDUCERE)

if (TITLU_STIINTIFIC was not defaulted) then v_pr_TITLU_STIINTIFIC=to_num(TITLU_STIINTIFIC)

if (JOB_KF_INDEMNIZ_CONDUCERE <> '-77') then


v_id_CONDUCERE =to_num(JOB_KF_INDEMNIZ_CONDUCERE)
if (INDEMNIZ_CONDUCERE was not defaulted) then v_id_CONDUCERE= INDEMNIZ_CONDUCERE

/* -------------------------------------------------------------------------
End: Procent spor
------------------------------------------------------------------------- */

return
/* Sporuri negociate Procente */
v_pr_Vechime,
v_pr_FIDELITATE,
v_id_FUNCTIE_SUPLIMENTARA,
v_pr_SISTEMATIC,
v_pr_LIMBA_STRAINA,
v_pr_TRACTARE,
v_pr_GESTIUNE,
v_pr_SEF_ECHIPA,
v_pr_CONDUCERE,
v_pr_TITLU_STIINTIFIC,
v_id_CONDUCERE

/* End: Formula: SPORURI_NEGOCIATE */

SPORURI_REALIZATE

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPORURI_REALIZATE */

default for PROCENT_SPOR_VECHIME_ASG_RUN is 0


default for PROCENT_SPOR_FIDELITATE_ASG_RUN is 0
default for PROCENT_SPOR_SISTEMATIC_ASG_RUN is 0
default for PROCENT_SPOR_LIMBA_STRAINA_ASG_RUN is 0
default for PROCENT_SPOR_TRACTARE_ASG_RUN is 0
default for PROCENT_SPOR_GESTIUNE_ASG_RUN is 0
default for PROCENT_SPOR_SEF_ECHIPA_ASG_RUN is 0
default for PROCENT_SPOR_CONDUCERE_ASG_RUN is 0
default for PROCENT_SPOR_TITLU_STIINTIFIC_ASG_RUN is 0
default for INDEMNIZATIE_CONDUCERE_ASG_RUN is 0
default for INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN is 0
default for ELEMENT_NAME is ' '
default for ORE_LUCRATE_LUNA_ASG_RUN is 0
default for ORE_LUCRATOARE_LUNA_ASG_RUN is 0
default for ORE_AN_LUNA_ASG_RUN is 0

default for ORE_SAMBATA_LUNA_ASG_MONTH is 0


default for ORE_DUMINICA_LUNA_ASG_MONTH is 0
default for ORE_SARBATORI_LUNA_ASG_MONTH is 0
default for ORE_SUPLIMENTARE_LUNA_ASG_MONTH is 0
default for ORE_NOAPTE_LUNA_ASG_MONTH is 0
default for PAY_PROC_PERIOD_END_DATE IS '01-FEB-1900' (DATE)

/* -------------------------------
Sporuri permanente
------------------------------- */

if PROCENT_SPOR_TITLU_STIINTIFIC_ASG_RUN <> 0 then


(
v_l_titlust = ELEMENT_NAME
v_p_titlust = PROCENT_SPOR_TITLU_STIINTIFIC_ASG_RUN
v_o_titlust = ORE_LUCRATOARE_LUNA_ASG_RUN
)

if (PROCENT_SPOR_CONDUCERE_ASG_RUN <> 0 or
INDEMNIZATIE_CONDUCERE_ASG_RUN <> 0) and
ORE_LUCRATE_LUNA_ASG_RUN <> 0 then
(
v_l_conducere = ELEMENT_NAME
v_p_conducere = PROCENT_SPOR_CONDUCERE_ASG_RUN
+ INDEMNIZATIE_CONDUCERE_ASG_RUN
v_o_conducere = ORE_LUCRATE_LUNA_ASG_RUN
)

if PROCENT_SPOR_SEF_ECHIPA_ASG_RUN <> 0 and


ORE_LUCRATE_LUNA_ASG_RUN <> 0 then
(
v_l_sefec = ELEMENT_NAME
v_p_sefec = PROCENT_SPOR_SEF_ECHIPA_ASG_RUN
v_o_sefec = ORE_LUCRATE_LUNA_ASG_RUN
)

if PROCENT_SPOR_GESTIUNE_ASG_RUN <> 0 and


ORE_LUCRATE_LUNA_ASG_RUN <> 0 then
(
v_l_gestiune = ELEMENT_NAME
v_p_gestiune = PROCENT_SPOR_GESTIUNE_ASG_RUN
v_o_gestiune = ORE_LUCRATE_LUNA_ASG_RUN
)

if PROCENT_SPOR_TRACTARE_ASG_RUN <> 0 and


ORE_LUCRATE_LUNA_ASG_RUN <> 0 then
(
v_l_tractare = ELEMENT_NAME
v_p_tractare = PROCENT_SPOR_TRACTARE_ASG_RUN
v_o_tractare = ORE_LUCRATE_LUNA_ASG_RUN
)

if PROCENT_SPOR_LIMBA_STRAINA_ASG_RUN <> 0 then


(
v_l_lbs = ELEMENT_NAME
v_p_lbs = PROCENT_SPOR_LIMBA_STRAINA_ASG_RUN
v_o_lbs = ORE_LUCRATOARE_LUNA_ASG_RUN
)

if INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN <> 0 and


ORE_LUCRATE_LUNA_ASG_RUN <> 0 then
(
v_l_fsupl = ELEMENT_NAME
v_id_fsupl = INDEMNIZATIE_FUNCTIE_SUPLIMENTARA_ASG_RUN
v_o_fsupl = ORE_LUCRATE_LUNA_ASG_RUN
)

if PROCENT_SPOR_SISTEMATIC_ASG_RUN <> 0 then


(
v_l_sistematic = ELEMENT_NAME
v_p_sistematic = PROCENT_SPOR_FIDELITATE_ASG_RUN
v_o_sistematic = ORE_LUCRATOARE_LUNA_ASG_RUN
)

if PROCENT_SPOR_VECHIME_ASG_RUN <> 0 and


ORE_LUCRATE_LUNA_ASG_RUN <> 0 then
(
v_l_vechime = ELEMENT_NAME
v_p_vechime = PROCENT_SPOR_VECHIME_ASG_RUN
v_o_vechime = ORE_LUCRATE_LUNA_ASG_RUN
)

if PROCENT_SPOR_FIDELITATE_ASG_RUN <> 0 and


ORE_LUCRATE_LUNA_ASG_RUN <> 0 and
ORE_AN_LUNA_ASG_RUN = 0 then
(
v_l_fidelitate = ELEMENT_NAME
v_p_fidelitate = PROCENT_SPOR_FIDELITATE_ASG_RUN
v_o_fidelitate = ORE_LUCRATE_LUNA_ASG_RUN
)

/* -------------------------------
End: Sporuri permanente
------------------------------- */

/* -------------------------------
Sporuri nepermanente
------------------------------- */
eff_date = PAY_PROC_PERIOD_END_DATE

v_pr_neg = to_num(GET_TABLE_VALUE('Sporuri negociate', 'Nepermanente', 'SAMB', eff_date))


if v_pr_neg <> 0 and
ORE_SAMBATA_LUNA_ASG_MONTH <> 0 then
(
v_l_samb = ELEMENT_NAME
v_p_samb = v_pr_neg
v_o_samb = ORE_SAMBATA_LUNA_ASG_MONTH
)

v_pr_neg = to_num(GET_TABLE_VALUE('Sporuri negociate', 'Nepermanente', 'DUM', eff_date))


if v_pr_neg <> 0 and
ORE_DUMINICA_LUNA_ASG_MONTH <> 0 then
(
v_l_dum = ELEMENT_NAME
v_p_dum = v_pr_neg
v_o_dum = ORE_DUMINICA_LUNA_ASG_MONTH
)

v_pr_neg = to_num(GET_TABLE_VALUE('Sporuri negociate', 'Nepermanente', 'SARB', eff_date))


if v_pr_neg <> 0 and
ORE_SARBATORI_LUNA_ASG_MONTH <> 0 then
(
v_l_sarb = ELEMENT_NAME
v_p_sarb = v_pr_neg
v_o_sarb = ORE_SARBATORI_LUNA_ASG_MONTH
)

v_pr_neg = to_num(GET_TABLE_VALUE('Sporuri negociate', 'Nepermanente', 'SUPLIM', eff_date))


if v_pr_neg <> 0 and
ORE_SUPLIMENTARE_LUNA_ASG_MONTH <> 0 then
(
v_l_suplim = ELEMENT_NAME
v_p_suplim = v_pr_neg
v_o_suplim = ORE_SUPLIMENTARE_LUNA_ASG_MONTH
)

v_pr_neg = to_num(GET_TABLE_VALUE('Sporuri negociate', 'Nepermanente', 'NOAPTE', eff_date))


if v_pr_neg <> 0 and
ORE_NOAPTE_LUNA_ASG_MONTH <> 0 then
(
v_l_noapte = ELEMENT_NAME
v_p_noapte = v_pr_neg
v_o_noapte = ORE_NOAPTE_LUNA_ASG_MONTH
)

/* -------------------------------
End: Sporuri nepermanente
------------------------------- */

return
/* Spor Noapte */
v_l_noapte,
v_p_noapte,
v_o_noapte,

/* Spor Ore Suplimentare */


v_l_suplim,
v_p_suplim,
v_o_suplim,

/* Spor Sarbatori */
v_l_sarb,
v_p_sarb,
v_o_sarb,

/* Spor Duminica */
v_l_dum,
v_p_dum,
v_o_dum,

/* Spor Sambata */
v_l_samb,
v_p_samb,
v_o_samb,

/* Spor Titlu stiintific */


v_l_titlust,
v_p_titlust,
v_o_titlust,

/* Spor Conducere / Indemniz */


v_l_conducere,
v_p_conducere,
v_o_conducere,

/* Spor Sef Echipa */


v_l_sefec,
v_p_sefec,
v_o_sefec,

/* Spor Gestiune */
v_l_gestiune,
v_p_gestiune,
v_o_gestiune,

/* Spor Tractare */
v_l_tractare,
v_p_tractare,
v_o_tractare,

/* Spor Limba Straina */


v_l_lbs,
v_p_lbs,
v_o_lbs,

/* Spor Functie Suplimentara */


v_l_fsupl,
v_id_fsupl,
v_o_fsupl,

/* Spor Sistematic */
v_l_sistematic,
v_p_sistematic,
v_o_sistematic,

/* Spor Vechime */
v_l_vechime,
v_p_vechime,
v_o_vechime,

/* Spor Fidelitate */
v_l_fidelitate,
v_p_fidelitate,
v_o_fidelitate

/* End: Formula: SPORURI_REALIZATE */

SPOR_CASIER

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/
/* Formula: SPOR_CASIER */

default for PR_SPCASIER is 0


default for ELEMENT_NAME is ' '

v_pr_spor = PR_SPCASIER
v_lansare = ELEMENT_NAME

return
v_pr_spor,
v_lansare

/* End: Formula: SPOR_CASIER */

SPOR_CASIER_NEGOCIAT

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPOR_CASIER_NEGOCIAT */

default for PR_SPCASIER is 0


default for SALARIU_BAZA_NEGOCIAT_ASG_RUN is 0

v_pr_spor = PR_SPCASIER
v_spor = round(SALARIU_BAZA_NEGOCIAT_ASG_RUN * PR_SPCASIER / 100)

return
v_pr_spor,
v_spor

/* End: Formula: SPOR_CASIER_NEGOCIAT */

SPOR_CASIER_REALIZAT

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPOR_CASIER_REALIZAT */

default for SPOR_CASIER_PROCENT_ASG_RUN is 0


/*default for SALARII_ASG_RUN is 0*/
/* Salariu baza realizat */
default for SALARIU_BAZA_ORAR_ASG_RUN is 0
default for SALARIU_BAZA_LUNAR_ASG_RUN is 0

default for ZILE_LUCRATOARE_LUNA_ASG_RUN is 0

default for ORE_LUCRATE_LUNA_ASG_RUN is 0


default for ZILE_LUCRATE_LUNA_ASG_RUN is 0

v_ore = ORE_LUCRATE_LUNA_ASG_RUN
v_zile = ZILE_LUCRATE_LUNA_ASG_RUN
v_salariu_orar = SALARIU_BAZA_ORAR_ASG_RUN

if (ZILE_LUCRATE_LUNA_ASG_RUN = ZILE_LUCRATOARE_LUNA_ASG_RUN)
then
v_salariu_realizat = SALARIU_BAZA_LUNAR_ASG_RUN
else
v_salariu_realizat = round(v_ore * v_salariu_orar)
/* End: Salariu baza realizat */

v_pr= SPOR_CASIER_PROCENT_ASG_RUN
/*v_sal_realizat = SALARII_ASG_RUN*/
v_spor = round(v_salariu_realizat * v_pr / 100)

return
v_pr,
v_spor

/* End: Formula: SPOR_CASIER_REALIZAT */

SPOR_NECONCURENTA_REALIZAT

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPOR_NECONCURENTA_REALIZAT */

default for SPOR_NECONCURENTA_PROCENT_ASG_RUN is 0


default for SALARII_ASG_RUN is 0

v_pr_spor = SPOR_NECONCURENTA_PROCENT_ASG_RUN
v_sal_realizat = SALARII_ASG_RUN
v_spor_neconcurenta = round(v_sal_realizat * v_pr_spor / 100)

return
v_pr_spor,
v_spor_neconcurenta

/* End: Formula: SPOR_NECONCURENTA_REALIZAT */


SPOR_TIMP_SUPLIMENTAR_NEGOCIAT

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPOR_TIMP_SUPLIMENTAR_NEGOCIAT */

default for PR_ORE_SUPL is 0

v_pr_spor = PR_ORE_SUPL

return v_pr_spor

/* End: Formula: SPOR_TIMP_SUPLIMENTAR_NEGOCIAT */

SPOR_TIMP_SUPLIMENTAR_REALIZAT

/* *******************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: SPOR_TIMP_SUPLIMENTAR_REALIZAT */

/* in zile de program normal */


default for SPOR_TIMP_SUPLIMENTAR_PROCENT_ASG_RUN is 0
default for SALARIU_BAZA_ORAR_ASG_RUN is 0
default for ORE_LMMJV_LUNA_ASG_RUN is 0

v_pr = SPOR_TIMP_SUPLIMENTAR_PROCENT_ASG_RUN
v_sal_orar = SALARIU_BAZA_ORAR_ASG_RUN
v_ore = ORE_LMMJV_LUNA_ASG_RUN

v_spor = round(v_sal_orar * v_ore * ( 1 + v_pr / 100))

return
v_pr,
v_ore,
v_spor

/* End: Formula: SPOR_TIMP_SUPLIMENTAR_REALIZAT */

STIMULENTE

/* *******************************************************************
* *

* Copyright (C) 2003 Reprezentanta Oracle Corporation, *

* Romania *

* All rights reserved. *

* *

******************************************************************/

/* Formula: STIMULENTE */

default for STIMULENTE_ASG_MONTH is 0

v_stimulente = STIMULENTE_ASG_MONTH

if (v_stimulente <> 0) then v_suma = v_stimulente

return

v_stimulente,

/* Conta Stimulente */

v_suma

/* End: Formula: STIMULENTE */

SUSPENDARE_CONTRACT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/
/* Formula: SUSPENDARE_CONTRACT */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
default for MOTIV is ' '
default for ORE is 0
default for ZILE is 0

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
ORE,
ZILE,
MOTIV

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

v_data_inceput_absenta = DATA_INCEPUT
v_data_sfarsit_absenta = DATA_SFARSIT

/* ---------------------------------------------------------------------------------------
luna
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, v_data_inceput_absenta)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, v_data_sfarsit_absenta)

v_zile_calendaristice = DAYS_BETWEEN(v_data_sfarsit, v_data_inceput) + 1


v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile = v_z
if
/*sunt in luna */
(v_zile > 0) and
/* am introdus date manual */
(ZILE was not defaulted) then
v_zile = ZILE

v_ore = v_zile * v_durata_muncii


if
/*sunt in chenzina I */
(v_ore > 0) and
/* am introdus date manual */
(ORE was not defaulted) then
v_ore = ORE
/* ---------------------------------------------------------------------------------------
End: luna
--------------------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------------------
chenzina I
--------------------------------------------------------------------------------------- */
If (v_plata = 'C')
then
( /* N 1 */

/* (1-15 ale lunii) */


v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)

/* nr de zile lucratoare din chenzina I


------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, v_data_inceput_absenta)
v_data_sfarsit = least(v_d_15, v_data_sfarsit_absenta)
v_zile_chenzina_I = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile_chenzina_I /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile_chenzina_I = v_z
if
/*sunt in chenzina I */
(v_zile_chenzina_I > 0) and
/* am introdus date manual */
(ZILE was not defaulted) then
v_zile_chenzina_I = ZILE

v_ore_chenzina_I = v_zile_chenzina_I * v_durata_muncii


if
/*sunt in chenzina I */
(v_ore_chenzina_I > 0) and
/* am introdus date manual */
(ORE was not defaulted) then
v_ore_chenzina_I = ORE

) /* N 1 */
/* ---------------------------------------------------------------------------------------
End: chenzina I
--------------------------------------------------------------------------------------- */

/* stop
-----------------------------------------------------------------------------------*/
if (DATA_SFARSIT <= PAY_PROC_PERIOD_END_DATE) then
v_stop = 'Stop ' + ELEMENT_NAME

return
/* comune */
v_data_inceput_absenta,
v_data_sfarsit_absenta,

/* SC luna */
v_zile_calendaristice,
v_zile,
v_ore,

v_stop,

/* SC chenzina I */
v_zile_chenzina_I,
v_ore_chenzina_I

/* End: Formula: SUSPENDARE_CONTRACT */

TICHETE_DE_MASA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: TICHETE_DE_MASA */

default for ZILE_LUCRATE_LUNA_ASG_RUN is 0

v_nr = ZILE_LUCRATE_LUNA_ASG_RUN

return v_nr

/* End: Formula: TICHETE_DE_MASA */


TIMP_LUCRAT

/********************************************************************
* *
* Copyright (C) 2004 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: TIMP_LUCRAT */

default for TIMP_LUCRAT_SAMBATA_DEFAULT is 0


default for TIMP_LUCRAT_DUMINICA_DEFAULT is 0
default for TIMP_LUCRAT_Sarbatori_DEFAULT is 0
default for TIMP_LUCRAT_Suplimentare_DEFAULT is 0
default for TIMP_LUCRAT_Noapte_DEFAULT is 0

default for TIMP_L_SAMB_ASG_RUN is 0


default for TIMP_L_DUM_ASG_RUN is 0
default for TIMP_L_SARB_ASG_RUN is 0
default for TIMP_L_SUPL_ASG_RUN is 0
default for TIMP_L_NOAPTE_ASG_RUN is 0

default for TIMP_L_SAMB_CN_ASG_RUN is 0


default for TIMP_L_DUM_CN_ASG_RUN is 0
default for TIMP_L_SARB_CN_ASG_RUN is 0
default for TIMP_L_SUPL_CN_ASG_RUN is 0
default for TIMP_L_NOAPTE_CN_ASG_RUN is 0

default for TIMP_L_SAMB_CD_ASG_RUN is 0


default for TIMP_L_DUM_CD_ASG_RUN is 0
default for TIMP_L_SARB_CD_ASG_RUN is 0
default for TIMP_L_SUPL_CD_ASG_RUN is 0
default for TIMP_L_NOAPTE_CD_ASG_RUN is 0

/* ---------------------------------------------------------------------------------------
Default
--------------------------------------------------------------------------------------- */

if TIMP_LUCRAT_SAMBATA_DEFAULT was not defaulted then


v_sambata = TIMP_LUCRAT_SAMBATA_DEFAULT

if TIMP_LUCRAT_DUMINICA_DEFAULT was not defaulted then


v_duminica = TIMP_LUCRAT_DUMINICA_DEFAULT

if TIMP_LUCRAT_Sarbatori_DEFAULT was not defaulted then


v_Sarbatori = TIMP_LUCRAT_Sarbatori_DEFAULT

if TIMP_LUCRAT_Noapte_DEFAULT was not defaulted then


v_Noapte = TIMP_LUCRAT_Noapte_DEFAULT

if TIMP_LUCRAT_Suplimentare_DEFAULT was not defaulted then


v_Suplimentare = TIMP_LUCRAT_Suplimentare_DEFAULT
v_t = 'N'
v_t_cm = 'N'

/* datele sunt introduse in E- Timp L (fara specificarea conditiilor de munca) */


if TIMP_L_SAMB_ASG_RUN <> 0 or
TIMP_L_DUM_ASG_RUN <> 0 or
TIMP_L_SARB_ASG_RUN <> 0 or
TIMP_L_SUPL_ASG_RUN <> 0 or
TIMP_L_NOAPTE_ASG_RUN <> 0 then v_t = 'Y'

/* datele sunt introduse in E- Timp L CN, CD (cu specificarea conditiilor de munca) */


if TIMP_L_SAMB_CN_ASG_RUN <> 0 or
TIMP_L_DUM_CN_ASG_RUN <> 0 or
TIMP_L_SARB_CN_ASG_RUN <> 0 or
TIMP_L_SUPL_CN_ASG_RUN <> 0 or
TIMP_L_NOAPTE_CN_ASG_RUN <> 0 or

TIMP_L_SAMB_CD_ASG_RUN <> 0 or
TIMP_L_DUM_CD_ASG_RUN <> 0 or
TIMP_L_SARB_CD_ASG_RUN <> 0 or
TIMP_L_SUPL_CD_ASG_RUN <> 0 or
TIMP_L_NOAPTE_CD_ASG_RUN <> 0 then v_t_cm = 'Y'

if v_t = 'Y' and v_t_cm = 'N' then


(
v_t = 'Y'
v_sambata = TIMP_L_SAMB_ASG_RUN
v_duminica = TIMP_L_DUM_ASG_RUN
v_Sarbatori = TIMP_L_SARB_ASG_RUN
v_Noapte = TIMP_L_NOAPTE_ASG_RUN
v_Suplimentare = TIMP_L_SUPL_ASG_RUN
)

if (v_t = 'N' and v_t_cm = 'Y') or (v_t = 'Y' and v_t_cm = 'Y') then
(
v_sambata = TIMP_L_SAMB_CN_ASG_RUN + TIMP_L_SAMB_CD_ASG_RUN
v_duminica = TIMP_L_DUM_CN_ASG_RUN + TIMP_L_DUM_CD_ASG_RUN
v_Sarbatori = TIMP_L_SARB_CN_ASG_RUN + TIMP_L_SARB_CD_ASG_RUN
v_Noapte = TIMP_L_NOAPTE_CN_ASG_RUN + TIMP_L_NOAPTE_CD_ASG_RUN
v_Suplimentare = TIMP_L_SUPL_CN_ASG_RUN + TIMP_L_SUPL_CD_ASG_RUN
)

/* ---------------------------------------------------------------------------------------
End: Default
--------------------------------------------------------------------------------------- */

return
v_sambata,
v_duminica,
v_Sarbatori,
v_Noapte,
v_Suplimentare

/* End: Formula: TIMP_LUCRAT */


TIMP_NELUCRAT

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: TIMP_NELUCRAT

/* Timp Nelucrat
Absenta Nemotivata >> AN Suspendare contract
Invoire
Concediu Fara Plata */
default for DATA_INCEPUT is '01-FEB-2000' (date)
default for DATA_SFARSIT is '01-FEB-2000' (date)
default for ORE is 0
default for ZILE is 0
default for Ora_inceput is 0
default for Ora_sfarsit is 0
/* End: Timp Nelucrat */

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0
default for JOB_KF_ALOCATIE_CARBUNE is '0'
default for COST_TONA_CARBUNE is 0
default for ROT is 0
default for PROCESARE_2_ASG_RUN is 0 /* Calcul luna */

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
ORE,
ZILE,
Ora_inceput,
Ora_sfarsit

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU) then


v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

/* Motiv
------------------ */
/* Absenta Nemotivata */
v_motiv_suspendare = '51_7'

/* End: Motiv
------------------ */

v_data_inceput_absenta = DATA_INCEPUT
v_data_sfarsit_absenta = DATA_SFARSIT
v_Ora_inceput_absenta = ORA_INCEPUT
v_Ora_sfarsit_absenta = ORA_SFARSIT

/* Timp Nelucrat */
/* nr de zile din luna
----------------------*/
v_d_i = greatest( PAY_PROC_PERIOD_START_DATE, v_data_inceput_absenta)
v_d_s = least(PAY_PROC_PERIOD_END_DATE, v_data_sfarsit_absenta)

v_zile_calendaristice = DAYS_BETWEEN(v_d_s, v_d_i) + 1


v_zile = GET_WORKING_DAYS(v_d_i, v_d_s)
v_z = v_zile
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: nr de zile din luna
--------------------------------------------------------------------------------------*/
v_zile = v_z
v_ore = v_zile * v_durata_muncii
if
/*sunt in luna */
(v_ore > 0) and
/* am introdus date manual */
(ORE was not defaulted) then
v_ore = ORE

/* ---------------------------------------------------------------------------------------
chenzina I
--------------------------------------------------------------------------------------- */
If (V_PLATA = 'C')
then
( /* N 1 */

/* (1-15 ale lunii) */


v_d_15 = ADD_DAYS(PAY_PROC_PERIOD_START_DATE, 14)

/* nr de zile lucratoare din chenzina I


------------------------------------------------- */
v_d_i = greatest( PAY_PROC_PERIOD_START_DATE, v_data_inceput_absenta)
v_d_s = least(v_d_15, v_data_sfarsit_absenta)
v_zile_lucratoare_chenzina_I = GET_WORKING_DAYS(v_d_i, v_d_s)

v_z = v_zile_lucratoare_chenzina_I
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1

/* END: nr de zile lucratoare din chenzina I


------------------------------------------------*/
v_zile_lucratoare_chenzina_I = v_z
v_ore_lucratoare_chenzina_I = v_zile_lucratoare_chenzina_I * v_durata_muncii
if
/*sunt in chenzina I */
(v_ore_lucratoare_chenzina_I > 0) and
/* am introdus date manual */
(ORE was not defaulted) then
v_ore_lucratoare_chenzina_I = ORE

) /* N 1 */
/* ---------------------------------------------------------------------------------------
End: chenzina I
--------------------------------------------------------------------------------------- */

/* End: Timp Nelucrat */

/* ----------------------------------------------
Cota carbune retinere
----------------------------------------------- */
/* numai in Calcul luna */
if PROCESARE_2_ASG_RUN = 1 and
to_num(JOB_KF_ALOCATIE_CARBUNE) > 0 and v_ore > 7 then
(
v_cota = to_num(JOB_KF_ALOCATIE_CARBUNE)
v_cost = COST_TONA_CARBUNE
v_carb_ret = round(v_cost * v_cota/12, ROT) * -1
)

/* ---------------------------------------------
End: Cota carbune retinere
---------------------------------------------- */

/* stop
-----------------------------------------------------------------------------------*/
if (DATA_SFARSIT <= PAY_PROC_PERIOD_END_DATE) then v_stop = ELEMENT_NAME + ': Stop '

return
/* comune */
v_data_inceput_absenta,
v_data_sfarsit_absenta,

/* [Timp Nelucrat] [Luna] */


v_motiv_suspendare,
v_zile_calendaristice,
v_zile,
v_ore,

v_stop,

/* [Timp Nelucrat] [chenzina I] */


v_zile_lucratoare_chenzina_I,
v_ore_lucratoare_chenzina_I,
v_ora_inceput_absenta,
v_ora_sfarsit_absenta,

/* Cota alocatie carbune (numai daca elem este AN) */


v_carb_ret

/* End: Formula: TIMP_NELUCRAT */

TIMP_SUPLIMENTAR

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: TIMP_SUPLIMENTAR */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
default for ORE is 0
default for ZILE is 0
default for Ora_inceput is 0
default for Ora_sfarsit is 0
default for FEL is 'SAMBATA_DUMINICA'
/* cod
SAMBATA_DUMINICA- Ore lucrate in zilele de repaus saptamanal
LMMJV- Ore lucrate suplimentar in zilele normale de lucru
SARBATORI- Ore lucrate in zilele de sarbatori legale
*/

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
ORE,
ZILE,
FEL

d_i = DATA_INCEPUT
if DATA_INCEPUT was defaulted then d_i = PAY_PROC_PERIOD_START_DATE
d_s = DATA_SFARSIT
if DATA_SFARSIT was defaulted then d_s = PAY_PROC_PERIOD_END_DATE

v_m1 = ELEMENT_NAME
+ ': d_i=' + to_text(d_i, 'DAY')
+ ': Fel=' + FEL

z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')


z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */

/* -----------------
luna
------------------ */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, d_i)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, d_s)

/* Ore lucrate suplimentar in zilele normale de lucru (Luni, Marti, Miercuri, Joi, Vineri) */
if FEL = 'LMMJV' then
(
v_zile = GET_WORKING_DAYS(v_data_inceput, v_data_sfarsit)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_data_inceput /* data inceput */
v_d_s = v_data_sfarsit /* data sfarsit */
v_z = v_zile /* zilele ce vor fi corectate */
/* zi lucratoare in care nu se lucreaza
--------------------------------------------*/
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
/* zi libera in care se lucreaza
------------------------------------*/
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
v_zile = v_z
)
/* End: Ore lucrate suplimentar in zilele normale de lucru (Luni, Marti, Miercuri, Joi, Vineri) */

/* Ore lucrate in zilele de repaus saptamanal (sambata si duminica) */


if FEL = 'SAMBATA_DUMINICA' then
(
v_zi = v_data_inceput
v_zile = 0
/* este in weekend */
if (v_zi <= v_data_sfarsit and substr(to_text(v_zi, 'DAY'),1,1) = 'S') then v_zile = v_zile + 1
v_zi = ADD_DAYS(v_zi, 1)
/* este in weekend */
if (v_zi <= v_data_sfarsit and substr(to_text(v_zi, 'DAY'),1,1) = 'S') then v_zile = v_zile + 1
)
/* End: Ore lucrate in zilele de repaus saptamanal (sambata si duminica) */

v_zile_1 = v_zile
v_ore = v_zile * v_durata_muncii
v_ore_1 = v_ore

if
/*sunt in luna */
(v_zile > 0) and
/* am introdus date manual */
(ZILE was not defaulted) then
v_zile_1 = ZILE

v_ore = v_zile * v_durata_muncii


if
/*sunt in luna */
(v_ore > 0) and
/* am introdus date manual */
(ORE was not defaulted) then
v_ore_1 = ORE
/* ----------------
End: luna
----------------- */

/* ------------
stop
------------- */
if (d_s <= PAY_PROC_PERIOD_END_DATE) then v_stop = ELEMENT_NAME + ': Stop '
/* ------------
End: stop
------------- */

/* ------------
spor
------------- */

if FEL = 'SAMBATA_DUMINICA' then


(
v_lansare_SD = ELEMENT_NAME
d_i_sd = d_i
d_s_sd = d_s
v_zile_1_sd = v_zile_1
v_ore_1_sd = v_ore_1
)
if FEL = 'LMMJV' then
(
v_lansare_LMMJV = ELEMENT_NAME
d_i_lmmjv = d_i
d_s_lmmjv = d_s
v_zile_1_lmmjv = v_zile_1
v_ore_1_lmmjv = v_ore_1
)
/* ------------
End: spor
------------- */

return
/* [Timp Suplimentar] */
d_i, /* DATA_INCEPUT */
d_s, /* DATA_SFARSIT */

/* [Timp Suplimentar] [Luna] */


v_zile_1,
v_ore_1,

v_stop,
v_m1,

/* [SD] Timp suplimentar */


d_i_sd,
d_s_sd,
v_zile_1_sd,
v_ore_1_sd,

/* [LMMJV] Timp suplimentar */


d_i_lmmjv,
d_s_lmmjv,
v_zile_1_lmmjv,
v_ore_1_lmmjv,

/* [Spor negociat] */
v_lansare_LMMJV,
v_lansare_SD
/* End: Formula: TIMP_SUPLIMENTAR */

TN_LUNA

/* *******************************************************************
* *
* Copyright (C) 2003 Reprezentanta Oracle Corporation, *
* Romania *
* All rights reserved. *
* *
******************************************************************/

/* Formula: TN_LUNA */

default for DATA_INCEPUT is '01-FEB-2000' (date)


default for DATA_SFARSIT is '01-FEB-2000' (date)
/* numai pentru:
AN Suspendare contract
*/
default for Zile_lucratoare is 0
default for Ore_lucratoare is 0

default for DURATA_NORMALA_TIMP_LUCRU is 8


default for ELEMENT_NAME is ' '
default for PAY_PROC_PERIOD_START_DATE is '01-FEB-1900' (date)
default for PAY_PROC_PERIOD_END_DATE is '01-FEB-1900' (date)

/* standard setup */
default for ASG_HOURS is 8
/* custom setup */
default for PROGRAM_PARTIAL_ASG_RUN is 0

inputs are
DATA_INCEPUT,
DATA_SFARSIT,
/* numai pentru:
AN Suspendare contract
*/
Zile_lucratoare,
Ore_lucratoare

/* CSL: Plata C=Chenzinl sau L=Lunar */


v_plata = GET_TABLE_VALUE('Perioada plata', 'Periodicitate', '1')

/* zi lucratoare exceptie - zi lucratoare in care nu se lucreaza */


z_lu_1 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lu_2 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lu_3 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lu_4 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lu_5 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '5'), 'DD-MM-YY')
z_lu_6 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '6'), 'DD-MM-YY')
z_lu_7 = to_date(GET_TABLE_VALUE('Zi Lucratoare Exceptie', 'Data', '7'), 'DD-MM-YY')

/* zi libera exceptie - zi libera in care se lucreaza*/


/*--adica Sambata sau Duminica--*/
z_lb_1 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '1'), 'DD-MM-YY')
z_lb_2 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '2'), 'DD-MM-YY')
z_lb_3 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '3'), 'DD-MM-YY')
z_lb_4 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '4'), 'DD-MM-YY')
z_lb_5 = to_date(GET_TABLE_VALUE('Zi Libera Exceptie', 'Data', '5'), 'DD-MM-YY')

/*
Parttime = timp partial >> v_p_part > 0
Fulltime = timp normal (norma intreaga) >> v_p_part = 0
*/
v_p_part = PROGRAM_PARTIAL_ASG_RUN

/* ----------------------------------------------------------------------------------
Nr de ore pe zi
----------------------------------------------------------------------------------- */
v_durata_muncii = ASG_HOURS
if
/* custom setup */
(v_p_part > 0) then v_durata_muncii = v_p_part

if (v_durata_muncii > DURATA_NORMALA_TIMP_LUCRU)


then
v_durata_muncii = DURATA_NORMALA_TIMP_LUCRU

v_nr_ore = v_durata_muncii
if
/* numai pentru:
AN Suspendare contract
*/
(ZILE_lucratoare was not defaulted and ORE_lucratoare was not defaulted and
ZILE_lucratoare <>0 and ORE_lucratoare <> 0) then
v_nr_ore = round(ORE_lucratoare / ZILE_lucratoare)
/* ----------------------------------------------------------------------------------
End: Nr de ore pe zi
----------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------
TN zi
--------------------------------------------------------------------------------------- */
v_data_inceput = greatest( PAY_PROC_PERIOD_START_DATE, DATA_INCEPUT)
v_data_sfarsit = least(PAY_PROC_PERIOD_END_DATE, DATA_SFARSIT)

/* zi 1
------------------------------------------------------------------------*/
v_zi = PAY_PROC_PERIOD_START_DATE

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_1 = v_nr_ore
)

/* zi 2
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z
/* este o zi lucratoare */
if (x>0) then v_tn_2 = v_nr_ore
)

/* zi 3
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_3 = v_nr_ore
)

/* zi 4
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_4 = v_nr_ore
)

/* zi 5
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_5 = v_nr_ore
)

/* zi 6
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_6 = v_nr_ore
)

/* zi 7
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_7 = v_nr_ore
)

/* zi 8
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_8 = v_nr_ore
)

/* zi 9
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_9 = v_nr_ore
)

/* zi 10
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_10 = v_nr_ore
)

/* zi 11
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_11 = v_nr_ore
)
/* zi 12
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_12 = v_nr_ore
)

/* zi 13
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_13 = v_nr_ore
)

/* zi 14
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_14= v_nr_ore
)
/* zi 15
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_15 = v_nr_ore
)

/* zi 16
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_16 = v_nr_ore
)

/* zi 17
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_17 = v_nr_ore
)

/* zi 18
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_18 = v_nr_ore
)

/* zi 19
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */
if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_19 = v_nr_ore
)

/* zi 20
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_20 = v_nr_ore
)

/* zi 21
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_21 = v_nr_ore
)

/* zi 22
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1
if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_22 = v_nr_ore
)

/* zi 23
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_23 = v_nr_ore
)

/* zi 24
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)
/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* corectie nr de zile
------------------------------------------------- */
v_d_i = v_zi /* data inceput */
v_d_s = v_zi /* data sfarsit */
v_z = x /* zilele ce vor fi corectate */

if (Z_LU_1 >= v_d_i and Z_LU_1 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_2 >= v_d_i and Z_LU_2 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_3 >= v_d_i and Z_LU_3 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_4 >= v_d_i and Z_LU_4 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_5 >= v_d_i and Z_LU_5 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_6 >= v_d_i and Z_LU_6 <= v_d_s) Then v_z = v_z - 1
if (Z_LU_7 >= v_d_i and Z_LU_7 <= v_d_s) Then v_z = v_z - 1

if (Z_LB_1 >= v_d_i and Z_LB_1 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_2 >= v_d_i and Z_LB_2 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_3 >= v_d_i and Z_LB_3 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_4 >= v_d_i and Z_LB_4 <= v_d_s) Then v_z = v_z + 1
if (Z_LB_5 >= v_d_i and Z_LB_5 <= v_d_s) Then v_z = v_z + 1
/* END: corectie nr de zile
------------------------------------------------*/
x = v_z

/* este o zi lucratoare */
if (x>0) then v_tn_24 = v_nr_ore
)

/* zi 25
------------------------------------------------------------------------*/
v_zi = ADD_DAYS(v_zi, 1)

/* este in perioada de TN */
if (v_data_inceput <= v_zi and v_zi <= v_data_sfarsit) then
(
x = GET_WORKING_DAYS(v_zi, v_zi)

/* cor