Sie sind auf Seite 1von 28

1 PACKAGE BODY PKG_LOANrepay IS 2 3 V_ENTITY_NUM NUMBER(4); 4 CURR_CODE VARCHAR2(3); 5 CBD DATE; 6 W_SERIAL NUMBER(10) := 0; 7 W_TEMP_SER NUMBER(10); 8 9 10 PROCEDURE LOANREPAY

(ENTITY IN NUMBER, 11 BRNCODE IN NUMBER, 12 PRODCODE IN NUMBER, 13 INTNUM IN NUMBER, 14 FDATE IN DATE, 15 TDATE IN DATE, 16 SERIAL OUT NUMBER) IS 17 BEGIN 18 W_SERIAL:=0; 19 PKG_ENTITY.SP_SET_ENTITY_CODE(ENTITY); 20 V_ENTITY_NUM := PKG_ENTITY.FN_GET_ENTITY_CODE; 21 CURR_CODE := PKG_PB_GLOBAL.FN_GET_INS_BASE_CURR(V_ENTITY_NUM); 22 CBD := PKG_PB_GLOBAL.FN_GET_CURR_BUS_DATE(V_ENTITY_NUM); 23 SELECT PKG_PB_GLOBAL.SP_GET_REPORT_SL(PKG_ENTITY.FN_GET_ENTITY_CODE) 24 INTO W_TEMP_SER FROM DUAL; 25 BRNWISE(BRNCODE,PRODCODE,INTNUM,FDATE,TDATE); 26 SERIAL:= W_SERIAL; 27 END LOANREPAY; 28 29 30 PROCEDURE BRNWISE(BRNCODE1 IN NUMBER, 31 PRODCODE1 IN NUMBER, 32 INTNUM1 IN NUMBER, 33 FDATE1 IN DATE, 34 TDATE1 IN DATE) IS 35 BEGIN 36 IF (BRNCODE1 = 0) THEN 37 FOR IDX IN (SELECT B.MBRN_CODE FROM MBRN B WHERE B.MBRN_CLOSURE_DATE IS NULL ORDER BY B.MBRN_CODE) 38 LOOP 39 PRODWISE(IDX.MBRN_CODE, PRODCODE1, INTNUM1, FDATE1, TDATE1); 40 END LOOP; 41 ELSE 42 FOR IDX IN (SELECT B.MBRN_CODE FROM MBRN B WHERE B.MBRN_CODE = BRNCODE 1 AND B.MBRN_CLOSURE_DATE IS NULL ORDER BY B.MBRN_CODE) 43 LOOP 44 PRODWISE(IDX.MBRN_CODE, PRODCODE1, INTNUM1, FDATE1, TDATE1); 45 END LOOP; 46 END IF; 47 END BRNWISE; 48 49 50 PROCEDURE PRODWISE(BRNCODE2 IN NUMBER, 51 PRODCODE2 IN NUMBER, 52 INTNUM2 IN NUMBER, 53 FDATE2 IN DATE, 54 TDATE2 IN DATE ) IS 55 BEGIN 56 IF (PRODCODE2 = 0) THEN 57 FOR IDX1 IN (SELECT PM.LNPRD_PROD_CODE, PM.LNPRD_EQU_INSTALMNT_LOAN FRO M LNPRODPM PM ORDER BY PM.LNPRD_PROD_CODE)

58 LOOP 59 ACNTWISE(BRNCODE2,IDX1.LNPRD_PROD_CODE, INTNUM2, FDATE2, TDATE2); 60 END LOOP; 61 ELSE 62 FOR IDX1 IN (SELECT PM.LNPRD_PROD_CODE, PM.LNPRD_EQU_INSTALMNT_LOAN FRO M LNPRODPM PM WHERE PM.LNPRD_PROD_CODE = PRODCODE2 ) 63 LOOP 64 ACNTWISE(BRNCODE2,IDX1.LNPRD_PROD_CODE, INTNUM2, FDATE2, TDATE2); 65 END LOOP; 66 END IF; 67 END PRODWISE; 68 69 70 71 PROCEDURE ACNTWISE(BRNCODE3 IN NUMBER, 72 PRODCODE3 IN NUMBER, 73 INTNUM3 IN NUMBER, 74 FDATE3 IN DATE, 75 TDATE3 IN DATE) IS 76 BEGIN 77 IF( INTNUM3 = 0) THEN 78 FOR IDX2 IN (SELECT A.ACNTS_INTERNAL_ACNUM FROM ACNTS A, LOANACNT S LA WHERE A.ACNTS_ENTITY_NUM = V_ENTITY_NUM 79 AND A.ACNTS_ENTITY_NUM = LA.LNACNT_ENTITY_NUM 80 AND A.ACNTS_BRN_CODE = BRNCODE3 81 AND A.ACNTS_PROD_CODE = PRODCODE3 82 AND A.ACNTS_INTERNAL_ACNUM = LA.LNACNT_INTERNAL_ACNUM 83 AND A.ACNTS_AUTH_ON IS NOT NULL AND A.ACNTS_PROD_CODE = PRODCODE3 ) 84 LOOP 85 REPAY(IDX2.ACNTS_INTERNAL_ACNUM, FDATE3, TDATE3, BRNCODE3, PRO DCODE3); 86 END LOOP; 87 ELSE 88 FOR IDX2 IN (SELECT A.ACNTS_INTERNAL_ACNUM FROM ACNTS A, LOANACNT S LA WHERE A.ACNTS_ENTITY_NUM = V_ENTITY_NUM 89 AND A.ACNTS_ENTITY_NUM = LA.LNACNT_ENTITY_NUM 90 AND A.ACNTS_BRN_CODE = BRNCODE3 91 AND A.ACNTS_PROD_CODE = PRODCODE3 92 AND A.ACNTS_INTERNAL_ACNUM = LA.LNACNT_INTERNAL_ACNUM 93 AND A.ACNTS_INTERNAL_ACNUM = INTNUM3 AND A.ACNTS_AUTH_ON IS NOT N ULL) 94 LOOP 95 REPAY(IDX2.ACNTS_INTERNAL_ACNUM, FDATE3, TDATE3, BRNCODE3, PR ODCODE3); 96 END LOOP; 97 END IF; 98 END ACNTWISE; 99 100 101 PROCEDURE REPAY(INTNUM IN NUMBER, 102 FDATE IN DATE, 103 TDATE IN DATE, 104 BRNCODE IN NUMBER, 105 PRODCODE IN NUMBER)IS 106 107 QUERY_STR VARCHAR2(2000); 108 W_FYEAR VARCHAR2(4); 109 W_TYEAR VARCHAR2(4); 110 W_TRANDATE DATE;

111 W_TRANAMT NUMBER(18,3); 112 W_TRANBATCH NUMBER(18,3); 113 W_TRANBATSL NUMBER(18,3); 114 W_DISBAMOUNT NUMBER(18,3); 115 W_INTRATE VARCHAR2(100); 116 W_SANAMOUNT NUMBER(18,3); 117 W_SANDATE DATE; 118 W_DISBAMT NUMBER(18,3); 119 W_OSACBAL NUMBER(18,3); 120 W_OSBCBAL NUMBER(18,3); 121 W_ERR VARCHAR2(50); 122 W_TRN VARCHAR2(10); 123 W_OPENDATE DATE; 124 W_EMI CHAR(1); 125 W_TRANPRINAMT NUMBER(18,3); 126 W_TRANINTAMT NUMBER(18,3); 127 W_TRANCHARGES NUMBER(18,3); 128 129 TYPE R_CURSOR IS REF CURSOR; 130 TRANSACTIONS R_CURSOR; 131 132 BEGIN 133 134 135 W_INTRATE := FETCH_LOAN_INT(INTNUM,TDATE); 136 LIMITDTL(INTNUM,W_SANDATE,W_SANAMOUNT); 137 138 SELECT P.LNPRD_EQU_INSTALMNT_LOAN INTO W_EMI FROM LNPRODPM P 139 WHERE P.LNPRD_PROD_CODE = PRODCODE ; 140 IF (W_EMI = 1) THEN 141 SELECT SUM(D.LNACDISB_DISB_AMT) INTO W_DISBAMT 142 FROM LNACDISB D WHERE D.LNACDISB_ENTITY_NUM = V_ENTITY_NUM 143 AND D.LNACDISB_INTERNAL_ACNUM = INTNUM AND D.LNACDISB_AUTH_ON IS N OT NULL; 144 ELSIF (W_EMI = 0) THEN 145 SELECT A.ACNTS_OPENING_DATE INTO W_OPENDATE FROM ACNTS A 146 WHERE A.ACNTS_ENTITY_NUM = V_ENTITY_NUM AND A.ACNTS_INTERNAL_ACNUM = INTNUM AND 147 TRIM(A.ACNTS_AUTH_ON) IS NOT NULL; 148 149 W_FYEAR := SP_GETFINYEAR(V_ENTITY_NUM, W_OPENDATE); 150 W_TYEAR := SP_GETFINYEAR(V_ENTITY_NUM, TDATE); 151 152 IF W_FYEAR = W_TYEAR THEN 153 QUERY_STR := ' select SUM(tran_amount) '|| 154 ' from tran'||W_FYEAR || ' , tranadv'||W_FYEAR|| 155 ' where tran_entity_num = ' || V_ENTITY_NUM || 156 ' and TRAN_ENTITY_NUM = TRANADV_ENTITY_NUM '|| 157 ' and TRAN_BRN_CODE = TRANADV_BRN_CODE ' || 158 ' and TRAN_DATE_OF_TRAN = TRANADV_DATE_OF_TRAN ' || 159 ' and TRAN_BATCH_NUMBER = TRANADV_BATCH_NUMBER ' || 160 ' and TRAN_BATCH_SL_NUM = TRANADV_BATCH_SL_NUM ' || 161 ' and tran_internal_acnum = ' || INTNUM || 162 ' and tran_DB_CR_FLG = ''D'' ' || 163 ' and tran_date_of_tran >=''' || FDATE || 164 ' '' AND tran_date_of_tran <=''' || TDATE || 165 ' '' AND tranadv_prin_ac_amt <> 0' || 166 ' and tran_auth_on is not null ' || 167 ' order by tran_auth_on ' ; 168 EXECUTE IMMEDIATE QUERY_STR INTO W_DISBAMOUNT;

169 W_DISBAMT := W_DISBAMOUNT; 170 ELSE 171 WHILE (W_FYEAR <= W_TYEAR) LOOP 172 QUERY_STR := ' select SUM(tran_amount) '|| 173 ' from tran'||W_FYEAR || ' , tranadv'||W_FYEAR|| 174 ' where tran_entity_num = ' || V_ENTITY_NUM || 175 ' and TRAN_ENTITY_NUM = TRANADV_ENTITY_NUM '|| 176 ' and TRAN_BRN_CODE = TRANADV_BRN_CODE ' || 177 ' and TRAN_DATE_OF_TRAN = TRANADV_DATE_OF_TRAN ' || 178 ' and TRAN_BATCH_NUMBER = TRANADV_BATCH_NUMBER ' || 179 ' and TRAN_BATCH_SL_NUM = TRANADV_BATCH_SL_NUM ' || 180 ' and tran_internal_acnum = ' || INTNUM || 181 ' and tran_DB_CR_FLG = ''D'' ' || 182 ' and tran_date_of_tran >=''' || FDATE || 183 ' '' AND tran_date_of_tran <=''' || TDATE || 184 ' '' AND tranadv_prin_ac_amt <> 0' || 185 ' and tran_auth_on is not null ' || 186 ' order by tran_auth_on ' ; 187 OPEN TRANSACTIONS FOR QUERY_STR; 188 LOOP 189 FETCH TRANSACTIONS INTO W_DISBAMOUNT; 190 W_DISBAMT := W_DISBAMT+W_DISBAMOUNT; 191 W_DISBAMOUNT := NULL; 192 EXIT WHEN TRANSACTIONS%NOTFOUND; 193 END LOOP; 194 CLOSE TRANSACTIONS; 195 W_FYEAR := W_FYEAR +1; 196 END LOOP; 197 END IF; 198 END IF; 199 W_FYEAR := 0; 200 W_TYEAR := 0; 201 W_FYEAR := SP_GETFINYEAR(V_ENTITY_NUM, FDATE); 202 W_TYEAR := SP_GETFINYEAR(V_ENTITY_NUM, TDATE); 203 IF W_FYEAR = W_TYEAR THEN 204 QUERY_STR := ' select tran_date_of_tran, tran_amount, '|| 205 ' TRANADV_PRIN_AC_AMT,TRANADV_INTRD_AC_AMT,TRANADV_CHAR GE_AC_AMT '|| 206 ' from tran'||W_FYEAR || ' , tranadv'||W_FYEAR|| 207 ' where tran_entity_num = ' || V_ENTITY_NUM || 208 ' and TRAN_ENTITY_NUM = TRANADV_ENTITY_NUM '|| 209 ' and TRAN_BRN_CODE = TRANADV_BRN_CODE ' || 210 ' and TRAN_DATE_OF_TRAN = TRANADV_DATE_OF_TRAN ' || 211 ' and TRAN_BATCH_NUMBER = TRANADV_BATCH_NUMBER ' || 212 ' and TRAN_BATCH_SL_NUM = TRANADV_BATCH_SL_NUM ' || 213 ' and tran_internal_acnum = ' || INTNUM || 214 ' and tran_DB_CR_FLG = ''C'' ' || 215 ' and tran_amount <> 0 ' || 216 ' and tran_date_of_tran >= '''||FDATE|| 217 ' '' and tran_date_of_tran <= '''||TDATE|| 218 ' '' and tran_auth_on is not null ' || 219 ' order by tran_auth_on ' ; 220 OPEN TRANSACTIONS FOR QUERY_STR; 221 LOOP 222 FETCH TRANSACTIONS INTO W_TRANDATE, W_TRANAMT , W_TRANPRINAMT, W_TRANINTAMT, W_TRANCHARGES; 223 GET_ASON_ACBAL(V_ENTITY_NUM, INTNUM, CURR_COD E,W_TRANDATE, CBD, 224 W_OSACBAL,W_OSBCBAL,W_ERR,W_TRN); 225 IF W_TRANAMT IS NOT NULL THEN

226 INSERT INTO RTMPLNREPAY VALUES (V_ENTITY_N UM, W_TEMP_SER,BRNCODE,PRODCODE, 227 INTNUM , W_INTRATE, W_SANAMOUNT, W_SANDATE , W_DISBAMT, 228 W_SANDATE, W_TRANAMT, W_TRANDATE,W_TRANPRI NAMT, W_TRANINTAMT, W_TRANCHARGES, W_OSACBAL); 229 W_SERIAL := W_TEMP_SER; 230 END IF; 231 W_TRANAMT := NULL; 232 W_TRANDATE := NULL; 233 W_OSACBAL := NULL; 234 EXIT WHEN TRANSACTIONS%NOTFOUND; 235 END LOOP; 236 CLOSE TRANSACTIONS; 237 ELSE 238 WHILE (W_FYEAR <= W_TYEAR) LOOP 239 240 QUERY_STR := ' select tran_date_of_tran, tran_amount, '|| 241 ' TRANADV_PRIN_AC_AMT,TRANADV_INTRD_AC_AMT,TRANADV_CHAR GE_AC_AMT '|| 242 ' from tran'||W_FYEAR || ' , tranadv'||W_FYEAR|| 243 ' where tran_entity_num = ' || V_ENTITY_NUM || 244 ' and TRAN_ENTITY_NUM = TRANADV_ENTITY_NUM '|| 245 ' and TRAN_BRN_CODE = TRANADV_BRN_CODE ' || 246 ' and TRAN_DATE_OF_TRAN = TRANADV_DATE_OF_TRAN ' || 247 ' and TRAN_BATCH_NUMBER = TRANADV_BATCH_NUMBER ' || 248 ' and TRAN_BATCH_SL_NUM = TRANADV_BATCH_SL_NUM ' || 249 ' and tran_internal_acnum = ' || INTNUM || 250 ' and tran_DB_CR_FLG = ''C'' ' || 251 ' and tran_amount <> 0 ' || 252 ' and tran_date_of_tran >= '''||FDATE|| 253 ' '' and tran_date_of_tran <= '''||TDATE|| 254 ' '' and tran_auth_on is not null ' || 255 ' order by tran_auth_on ' ; 256 OPEN TRANSACTIONS FOR QUERY_STR; 257 LOOP 258 FETCH TRANSACTIONS INTO W_TRANDATE, W_TRANAMT, 259 W_TRANPRINAMT, W_TRANINTAMT, W_TRANCHARGES; 260 GET_ASON_ACBAL(V_ENTITY_NUM, INTNUM, CURR_CODE,W_T RANDATE, CBD, 261 W_OSACBAL,W_OSBCBAL,W_ERR,W_TRN); 262 IF W_TRANAMT IS NOT NULL THEN 263 INSERT INTO RTMPLNREPAY VALUES (V_ENTITY_NUM, W _TEMP_SER,BRNCODE,PRODCODE, 264 INTNUM , W_INTRATE, W_SANAMOUNT, W_SANDATE, W_D ISBAMT, 265 W_SANDATE, W_TRANAMT, W_TRANDATE,W_TRANPRINAMT, W_TRANINTAMT, W_TRANCHARGES, W_OSACBAL); 266 W_SERIAL := W_TEMP_SER; 267 END IF; 268 W_TRANAMT := NULL; 269 W_TRANDATE := NULL; 270 W_OSACBAL := NULL; 271 EXIT WHEN TRANSACTIONS%NOTFOUND; 272 END LOOP; 273 CLOSE TRANSACTIONS; 274 W_FYEAR := W_FYEAR +1; 275 END LOOP; 276 END IF; 277 END REPAY;

278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 FUNCTION FETCH_LOAN_INT(INTACCNUM IN NUMBER,W_TODATE DATE) RETURN VARCHAR IS 298 299 300 301 302 303 304 305 306 , 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 INTACCNUM, TO_CHAR(TO_DATE(W_TODATE, 'DD-MON-YY'), 'DD-MON-YYYY'), 0); IF TRIM(PKG_LOANINTRATEASON.PV_ERR_MSG) IS NULL THEN W_SINGLE_INT_RATE := PKG_LOANINTRATEASON.V_SINGLE_INT_RATE; IF W_SINGLE_INT_RATE > 0 THEN W_INT_RATE := W_SINGLE_INT_RATE; END IF; END IF; END CALL_LOANINTRATEASON; RETURN W_INT_RATE; END FETCH_LOAN_INT; W_SINGLE_INT_RATE NUMBER(7, 5) := 0; W_INT_RATE NUMBER(7, 5) := 0; BEGIN <<CALL_LOANINTRATEASON>> BEGIN PKG_LOANINTRATEASON.PV_ERR_MSG := ''; PKG_LOANINTRATEASON.SP_LOANINTRATEASON(PKG_ENTITY.FN_GET_ENTITY_CODE

PROCEDURE LIMITDTL(INTNUM IN NUMBER, LMTSANDT OUT DATE, SANAMT OUT NUMBER) IS W_SANDT DATE; W_SANAMT NUMBER(18,3); BEGIN FOR ID7 IN (SELECT * FROM LIMITLINE L, ACASLLDTL DT WHERE L.LMTLINE_ENTITY_NUM = DT.ACASLLDTL_ENTITY_NUM AND L.LMTLINE_CLIENT_CODE = DT.ACASLLDTL_CLIENT_NUM

336 AND L.LMTLINE_NUM = DT.ACASLLDTL_LIMIT_LINE_NUM 337 AND DT.ACASLLDTL_INTERNAL_ACNUM = INTNUM) 338 LOOP 339 W_SANDT := ID7.LMTLINE_LIMIT_EFF_DATE; 340 W_SANAMT := ID7.LMTLINE_SANCTION_AMT; 341 END LOOP; 342 LMTSANDT := W_SANDT; 343 SANAMT := W_SANAMT; 344 345 END LIMITDTL; 346 347 PROCEDURE LOANDISBDTL(INTNUM1 IN NUMBER, 348 DISB OUT VARCHAR2, 349 NOOFDISB OUT NUMBER ) IS 350 W_DISBAMT VARCHAR2(100) := '' ; 351 W_NOOFDISB NUMBER(2) := 0; 352 BEGIN 353 FOR IDX6 IN (SELECT * FROM LNACDISB D WHERE D.LNACDISB_ENTITY_NUM = V_EN TITY_NUM 354 AND D.LNACDISB_INTERNAL_ACNUM = INTNUM1 AND D.LNACDISB_AUTH_ON IS NOT NU LL ORDER BY D.LNACDISB_DISB_SL_NUM) 355 LOOP 356 W_NOOFDISB := W_NOOFDISB + 1; 357 W_DISBAMT := W_DISBAMT ||'~'||IDX6.LNACDISB_DISB_AMT||','|| IDX6.LNAC DISB_DISB_ON ; 358 359 END LOOP; 360 NOOFDISB := W_NOOFDISB; 361 DISB := W_DISBAMT; 362 END LOANDISBDTL; 363 END PKG_LOANREPAY; ================================================================================ ================================================ 1 PACKAGE BODY PKG_LNODUPDATE AS 2 3 4 W_ACNT_BRN_CODE NUMBER(4); 5 6 7 W_PROCESS_DATE DATE; 8 V_SESS_USER_ID VARCHAR2(8); 9 W_COUNT NUMBER(5) DEFAULT 0; 10 W_ERROR_MSG VARCHAR2(1300); 11 E_USER_EXCEP EXCEPTION; 12 13 PROCEDURE UPDATE_LNODCNTL; 14 PROCEDURE UPDATE_LNODCNTL IS 15 BEGIN 16 SELECT COUNT(*) 17 INTO W_COUNT 18 FROM LNODCNTL 19 WHERE LNODCNTL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE 20 AND LNODCNTL_NUM = '1'; 21 IF (W_COUNT = 0) THEN 22 INSERT INTO LNODCNTL 23 VALUES 24 (PKG_ENTITY.FN_GET_ENTITY_CODE, 1, W_PROCESS_DATE, V_SESS_USER_ID) ;

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

ELSE UPDATE LNODCNTL SET LNODCNTL_LAST_PROC_DATE = W_PROCESS_DATE, LNODCNTL_PROC_BY = V_SESS_USER_ID WHERE LNODCNTL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNODCNTL_NUM = '1'; END IF; EXCEPTION WHEN OTHERS THEN W_ERROR_MSG := 'ERROR IN UPDATE_LNODCNTL'; RAISE E_USER_EXCEP; END UPDATE_LNODCNTL; PROCEDURE UPDATE_LNODCNTL_GLOBAL(V_ENTITY_NUM IN NUMBER) IS BEGIN PKG_ENTITY.SP_SET_ENTITY_CODE(V_ENTITY_NUM); <<CHECKLNOD>> BEGIN W_PROCESS_DATE := PKG_EODSOD_FLAGS.PV_CURRENT_DATE; V_SESS_USER_ID := PKG_EODSOD_FLAGS.PV_USER_ID; UPDATE_LNODCNTL; EXCEPTION WHEN OTHERS THEN IF TRIM(W_ERROR_MSG) IS NULL THEN W_ERROR_MSG := 'Error in Updating LNODCNTL ' || SUBSTR(SQLERRM, 1, 700); END IF; W_ERROR_MSG := W_ERROR_MSG; PKG_EODSOD_FLAGS.PV_ERROR_MSG := W_ERROR_MSG; END CHECKLNOD; END UPDATE_LNODCNTL_GLOBAL; PROCEDURE SP_LNODUPDATE(V_ENTITY_NUM P_BRN_CODE P_PROCESS_DATE P_CURR_BUS_DATE P_SESS_USER_ID W_OD_CALC_FLG NUMBER(1); W_IN_BRANCH_CODE NUMBER(6); PROCEDURE PROCEDURE PROCEDURE PROCEDURE PROCEDURE PROCEDURE PROCEDURE SP_GET_OVERDUE; SP_CHECK_DP; SP_CHECK_REPAY_DATE; SP_GET_REPAY_DATE; SP_GET_REPAY_DATE_SUB; UPDATE_LNOD; UPDATE_LNODHIST; IN IN IN IN IN NUMBER, NUMBER DEFAULT 0, VARCHAR2 DEFAULT NULL, VARCHAR2 DEFAULT NULL, VARCHAR2 DEFAULT NULL) IS

PROCEDURE CHECK_INPUTS; PROCEDURE INIT_PARA; PROCEDURE FETCH_TRAN; TYPE TY_ACNTS_REC IS RECORD( V_INTERNAL_ACNUM NUMBER(14), V_ACNT_BRN_CODE NUMBER(4),

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144

V_PROD_CODE NUMBER(4), V_CURR_CODE VARCHAR2(3), V_OPENING_DATE DATE, V_ENTD_ON DATE, V_PRODUCT_FOR_RUN_ACS CHAR(1) ); TYPE TAB_ACNTS_REC IS TABLE OF TY_ACNTS_REC INDEX BY PLS_INTEGER; IDX_REC_ACNTS TAB_ACNTS_REC; W_SQL_OD W_SQL W_CURR_BUS_DATE W_LAST_OD_UPDATE_DATE VARCHAR2(1300); VARCHAR2(2300); TIMESTAMP; DATE; DATE; NUMBER(14); NUMBER(4); VARCHAR2(3); DATE; VARCHAR2(1); NUMBER(12); NUMBER(12); VARCHAR2(1); DATE DEFAULT NULL; VARCHAR2(1); NUMBER(18, 3) DEFAULT 0; NUMBER(5) DEFAULT 0; VARCHAR2(1) DEFAULT 0; VARCHAR2(1) DEFAULT 0; VARCHAR2(1) DEFAULT 0; 0; 0; 0; 0; 0; 0; 0; 0; 0;

V_LNDP_DP_VALID_UPTO_DATE V_ACNTS_INTERNAL_ACNUM V_ACNTS_PROD_CODE V_ACNTS_CURR_CODE V_LIMIT_EXPIRY_DATE V_LIMIT_DP_REQD V_ACASLL_CLINET_NUM V_ACASLL_LIMITLINE_NUM V_PROD_FOR_RUN_ACS W_REPAY_DATE W_REPAY_FREQ W_REPAY_AMT W_NOF_INSTALL W_EXIT W_EXIT_SUB W_PROC_OD W_OS_AMT W_OD_AMT W_OD_DATE W_LIMIT_AMT W_SANC_LIMIT_AMT W_DP_AMT W_PRIN_OD_AMT W_PRIN_OD_DATE W_INT_OD_AMT W_INT_OD_DATE W_CHGS_OD_AMT W_CHGS_OD_DATE W_LIMIT_CHECK_AMT W_DAYS W_CBD W_BRN_CODE W_OPENING_DATE W_ENTD_ON L_LAST_OD_UPDATE_DATE W_FIN_YEAR W_LAST_INT_APPL_DATE W_INT_GRACE_DAYS W_CHK_INT_GRACE_DATE W_SQL_ADV W_REPH_ON_AMT

NUMBER(18, 3) DEFAULT NUMBER(18, 3) DEFAULT DATE DEFAULT NULL; NUMBER(18, 3) DEFAULT NUMBER(18, 3) DEFAULT NUMBER(18, 3) DEFAULT NUMBER(18, 3) DEFAULT DATE DEFAULT NULL; NUMBER(18, 3) DEFAULT DATE DEFAULT NULL; NUMBER(18, 3) DEFAULT DATE DEFAULT NULL; NUMBER(18, 3) DEFAULT NUMBER; DATE; NUMBER(6); DATE; DATE; DATE; NUMBER(4); DATE; NUMBER; DATE; VARCHAR2(1500);

NUMBER(18, 3);

145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204

W_TOT_DISB_AMOUNT NUMBER(18, 3); W_PRODUCT_FOR_RUN_ACS CHAR(1) := ''; PROCEDURE INIT_PARA IS BEGIN W_SQL_OD W_SQL W_PROCESS_DATE W_CURR_BUS_DATE W_LAST_OD_UPDATE_DATE W_ERROR_MSG V_SESS_USER_ID V_LNDP_DP_VALID_UPTO_DATE V_ACNTS_INTERNAL_ACNUM V_ACNTS_PROD_CODE V_ACNTS_CURR_CODE V_LIMIT_EXPIRY_DATE V_LIMIT_DP_REQD V_ACASLL_CLINET_NUM V_ACASLL_LIMITLINE_NUM V_PROD_FOR_RUN_ACS W_REPAY_DATE W_REPAY_FREQ W_REPAY_AMT W_NOF_INSTALL W_EXIT W_EXIT_SUB W_PROC_OD W_COUNT W_OS_AMT W_OD_AMT W_OD_DATE W_LIMIT_AMT W_SANC_LIMIT_AMT W_DP_AMT W_PRIN_OD_AMT W_PRIN_OD_DATE W_INT_OD_AMT W_INT_OD_DATE W_CHGS_OD_AMT W_CHGS_OD_DATE W_LIMIT_CHECK_AMT W_DAYS W_CBD W_BRN_CODE L_LAST_OD_UPDATE_DATE W_FIN_YEAR W_LAST_INT_APPL_DATE W_INT_GRACE_DAYS W_CHK_INT_GRACE_DATE W_SQL_ADV END INIT_PARA; PROCEDURE SP_GET_OVERDUE IS V_TIME VARCHAR2(10); V_TEMP_DATE VARCHAR2(21); W_OD_DATE1 VARCHAR2(10); := := := :=

:= := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := := :=

''; ''; NULL; NULL; NULL; ''; ''; NULL; 0; 0; ''; NULL; ''; 0; 0; ''; NULL; ''; 0; 0; '0'; '0'; '0'; 0; 0; 0; NULL; 0; 0; 0; 0; NULL; 0; NULL; 0; NULL; 0; 0; NULL; 0; NULL; 0;

NULL; 0; NULL; '';

205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | 251 252 253 254 255 256 257 258 259 260 261 262 263

W_PRIN_OD_DATE1 VARCHAR2(10); W_INT_OD_DATE1 VARCHAR2(10); W_CHGS_OD_DATE1 VARCHAR2(10); BEGIN W_OD_CALC_FLG := 1; W_REPH_ON_AMT := 0; W_TOT_DISB_AMOUNT := 0; PKG_LNOVERDUE.SP_LNOVERDUE(PKG_ENTITY.FN_GET_ENTITY_CODE, V_ACNTS_INTERNAL_ACNUM, TO_CHAR(W_PROCESS_DATE, 'DD-MM-YYYY'), TO_CHAR(W_CURR_BUS_DATE, 'DD-MM-YYYY'), W_ERROR_MSG, W_OS_AMT, W_SANC_LIMIT_AMT, W_DP_AMT, W_LIMIT_AMT, W_OD_AMT, W_OD_DATE1, W_PRIN_OD_AMT, W_PRIN_OD_DATE1, W_INT_OD_AMT, W_INT_OD_DATE1, W_CHGS_OD_AMT, W_CHGS_OD_DATE1); IF (W_ERROR_MSG IS NOT NULL) THEN RAISE E_USER_EXCEP; END IF; W_REPH_ON_AMT := PKG_LNOVERDUE.P_REPH_ON_AMT; W_TOT_DISB_AMOUNT := PKG_LNOVERDUE.P_TOT_DISB_AMOUNT; W_OD_DATE := TO_DATE(W_OD_DATE1, 'DD-MM-YYYY'); W_PRIN_OD_DATE := TO_DATE(W_PRIN_OD_DATE1, 'DD-MM-YYYY'); W_INT_OD_DATE := TO_DATE(W_INT_OD_DATE1, 'DD-MM-YYYY'); W_CHGS_OD_DATE := TO_DATE(W_CHGS_OD_DATE1, 'DD-MM-YYYY'); IF (W_LIMIT_AMT > W_DP_AMT) THEN W_LIMIT_CHECK_AMT := W_DP_AMT; ELSE W_LIMIT_CHECK_AMT := W_LIMIT_AMT; END IF; <<GET_DATE_FORMAT>> BEGIN SELECT TO_CHAR(SYSDATE, 'HH24:MI:SS') INTO V_TIME FROM DUAL; V_TEMP_DATE := TO_CHAR(W_CURR_BUS_DATE, 'DD-MM-YYYY') || ' ' | V_TIME; W_CURR_BUS_DATE := TO_TIMESTAMP(V_TEMP_DATE, 'DD-MM-YYYY HH24:MI:SS'); END GET_DATE_FORMAT; UPDATE_LNOD; UPDATE_LNODHIST; EXCEPTION WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN SP_GET_OVERDUE'; END IF; RAISE E_USER_EXCEP; END SP_GET_OVERDUE;

264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323

PROCEDURE UPDATE_LNOD IS BEGIN SELECT COUNT(*) INTO W_COUNT FROM LNOD WHERE LNOD_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNOD_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM; IF (W_COUNT = 0) THEN INSERT INTO LNOD (LNOD_ENTITY_NUM, LNOD_INTERNAL_ACNUM, LNOD_LATEST_EFF_DATE, LNOD_CURR, LNOD_OS_BAL, LNOD_SANC_LIMIT_AMT, LNOD_DP_AMT, LNOD_LIMIT_CHK_AMT, LNOD_OD_AMT, LNOD_OD_DATE, LNOD_PRIN_OD_AMT, LNOD_PRIN_OD_DATE, LNOD_INT_OD_AMT, LNOD_INT_OD_DATE, LNOD_CHGS_OD_AMT, LNOD_CHGS_OD_DATE, LNOD_PROC_BY, LNOD_PROC_ON, LNOD_INT_ACCR_OD_AMT, LNOD_ACCR_INT_OD_DATE, LNOD_ACTUAL_DUE_AMT, LNOD_REPH_ON_AMT, LNOD_TOT_DISB_AMOUNT ) VALUES (PKG_ENTITY.FN_GET_ENTITY_CODE, V_ACNTS_INTERNAL_ACNUM, W_PROCESS_DATE, V_ACNTS_CURR_CODE, W_OS_AMT, W_SANC_LIMIT_AMT, W_DP_AMT, W_LIMIT_CHECK_AMT, W_OD_AMT, W_OD_DATE, W_PRIN_OD_AMT, W_PRIN_OD_DATE, W_INT_OD_AMT, W_INT_OD_DATE, W_CHGS_OD_AMT, W_CHGS_OD_DATE, V_SESS_USER_ID, W_CURR_BUS_DATE, 0, NULL, NVL(PKG_LNOVERDUE.P_ACTUAL_OD_AMT, 0), W_REPH_ON_AMT, W_TOT_DISB_AMOUNT ); ELSE

324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 ), 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382

UPDATE LNOD SET LNOD_LATEST_EFF_DATE LNOD_CURR LNOD_OS_BAL LNOD_SANC_LIMIT_AMT LNOD_DP_AMT LNOD_LIMIT_CHK_AMT LNOD_OD_AMT LNOD_OD_DATE LNOD_PRIN_OD_AMT LNOD_PRIN_OD_DATE LNOD_INT_OD_AMT LNOD_INT_OD_DATE LNOD_CHGS_OD_AMT LNOD_CHGS_OD_DATE LNOD_PROC_BY LNOD_PROC_ON LNOD_ACTUAL_DUE_AMT

= = = = = = = = = = = = = = = = =

W_PROCESS_DATE, V_ACNTS_CURR_CODE, W_OS_AMT, W_SANC_LIMIT_AMT, W_DP_AMT, W_LIMIT_CHECK_AMT, W_OD_AMT, W_OD_DATE, W_PRIN_OD_AMT, W_PRIN_OD_DATE, W_INT_OD_AMT, W_INT_OD_DATE, W_CHGS_OD_AMT, W_CHGS_OD_DATE, V_SESS_USER_ID, W_CURR_BUS_DATE, NVL(PKG_LNOVERDUE.P_ACTUAL_OD_AMT, 0

LNOD_REPH_ON_AMT = W_REPH_ON_AMT, LNOD_TOT_DISB_AMOUNT = W_TOT_DISB_AMOUNT WHERE LNOD_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNOD_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM; END IF; EXCEPTION WHEN OTHERS THEN W_ERROR_MSG := 'ERROR IN UPDATE_LNOD'; RAISE E_USER_EXCEP; END UPDATE_LNOD; PROCEDURE UPDATE_LNODHIST IS BEGIN SELECT COUNT(1) INTO W_COUNT FROM LNODHIST WHERE LNODHIST_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNODHIST_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM AND LNODHIST_EFF_DATE = W_PROCESS_DATE; IF (W_COUNT = 0) THEN INSERT INTO LNODHIST (LNODHIST_ENTITY_NUM, LNODHIST_INTERNAL_ACNUM, LNODHIST_EFF_DATE, LNODHIST_CURR, LNODHIST_OS_BAL, LNODHIST_SANC_LIMIT_AMT, LNODHIST_DP_AMT, LNODHIST_LIMIT_CHK_AMT, LNODHIST_OD_AMT, LNODHIST_OD_DATE, LNODHIST_PRIN_OD_AMT, LNODHIST_PRIN_OD_DATE, LNODHIST_INT_OD_AMT, LNODHIST_INT_OD_DATE, LNODHIST_CHGS_OD_AMT, LNODHIST_CHGS_OD_DATE, LNODHIST_PROC_BY, LNODHIST_PROC_ON, LNODHIST_INT_ACCR_OD_AMT, LNODHIST_ACCR_INT_OD_DATE,

383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442

LNODHIST_ACTUAL_DUE_AMT, LNODHIST_REPH_ON_AMT, LNODHIST_TOT_DISB_AMOUNT ) VALUES (PKG_ENTITY.FN_GET_ENTITY_CODE, V_ACNTS_INTERNAL_ACNUM, W_PROCESS_DATE, V_ACNTS_CURR_CODE, W_OS_AMT, W_SANC_LIMIT_AMT, W_DP_AMT, W_LIMIT_CHECK_AMT, W_OD_AMT, W_OD_DATE, W_PRIN_OD_AMT, W_PRIN_OD_DATE, W_INT_OD_AMT, W_INT_OD_DATE, W_CHGS_OD_AMT, W_CHGS_OD_DATE, V_SESS_USER_ID, W_CURR_BUS_DATE, 0, NULL, PKG_LNOVERDUE.P_ACTUAL_OD_AMT, W_REPH_ON_AMT, W_TOT_DISB_AMOUNT ); ELSE UPDATE LNODHIST SET LNODHIST_CURR = V_ACNTS_CURR_CODE, LNODHIST_OS_BAL = W_OS_AMT, LNODHIST_SANC_LIMIT_AMT = W_SANC_LIMIT_AMT, LNODHIST_DP_AMT = W_DP_AMT, LNODHIST_LIMIT_CHK_AMT = W_LIMIT_CHECK_AMT, LNODHIST_OD_AMT = W_OD_AMT, LNODHIST_OD_DATE = W_OD_DATE, LNODHIST_PRIN_OD_AMT = W_PRIN_OD_AMT, LNODHIST_PRIN_OD_DATE = W_PRIN_OD_DATE, LNODHIST_INT_OD_AMT = W_INT_OD_AMT, LNODHIST_INT_OD_DATE = W_INT_OD_DATE, LNODHIST_CHGS_OD_AMT = W_CHGS_OD_AMT, LNODHIST_CHGS_OD_DATE = W_CHGS_OD_DATE, LNODHIST_PROC_BY = V_SESS_USER_ID, LNODHIST_PROC_ON = W_CURR_BUS_DATE, LNODHIST_ACTUAL_DUE_AMT = PKG_LNOVERDUE.P_ACTUAL_OD_AMT, LNODHIST_REPH_ON_AMT = W_REPH_ON_AMT, LNODHIST_TOT_DISB_AMOUNT = W_TOT_DISB_AMOUNT WHERE LNODHIST_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNODHIST_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM AND LNODHIST_EFF_DATE = W_PROCESS_DATE; END IF; EXCEPTION WHEN OTHERS THEN W_ERROR_MSG := 'ERROR IN UPDATE_LNODHIST'; RAISE E_USER_EXCEP; END UPDATE_LNODHIST;

443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502

PROCEDURE CHECK_LATEST_LIMIT IS W_LIMIT_AMT_CHK NUMBER(18, 3); W_ACTUAL_LIMIT_AMT_CHK NUMBER(18, 3); W_ACTUAL_DP_AMT_CHK NUMBER(18, 3); W_ERROR VARCHAR2(1300); W_OD_LIMIT_AMT_CHK NUMBER(18, 3); W_OD_DP_AMT_CHK NUMBER(18, 3); W_OD_OS_AMT_CHK NUMBER(18, 3); W_ASON_ACBAL NUMBER(18, 3); W_ASON_BCBAL NUMBER(18, 3); W_CURR_BAL NUMBER(18, 3); BEGIN W_LIMIT_AMT_CHK := 0; W_ACTUAL_LIMIT_AMT_CHK := 0; W_ACTUAL_DP_AMT_CHK := 0; W_ERROR := ''; W_OD_LIMIT_AMT_CHK := 0; W_OD_DP_AMT_CHK := 0; W_OD_OS_AMT_CHK := 0; W_ASON_ACBAL := 0; W_ASON_BCBAL := 0; W_CURR_BAL := 0; PKG_SP_INTERFACE.SP_GETLMTASONDATE(PKG_ENTITY.FN_GET_ENTITY_CODE, 0, 0, V_ACNTS_INTERNAL_ACNUM, W_PROCESS_DATE, W_LIMIT_AMT_CHK, W_ACTUAL_LIMIT_AMT_CHK, W_ACTUAL_DP_AMT_CHK, W_ERROR); IF (W_ERROR IS NOT NULL) THEN RAISE E_USER_EXCEP; END IF; <<READASONBAL>> BEGIN GET_ASON_ACBAL(PKG_ENTITY.FN_GET_ENTITY_CODE, V_ACNTS_INTERNAL_ACNUM, V_ACNTS_CURR_CODE, W_PROCESS_DATE, W_CBD, W_ASON_ACBAL, W_ASON_BCBAL, W_ERROR); W_CURR_BAL := NVL(W_ASON_ACBAL, 0); IF (TRIM(W_ERROR) IS NOT NULL) THEN RAISE E_USER_EXCEP; END IF; END READASONBAL; <<LNODHISTREAD>> BEGIN SELECT L.LNODHIST_SANC_LIMIT_AMT, L.LNODHIST_DP_AMT, L.LNODHIST_OS_BAL INTO W_OD_LIMIT_AMT_CHK, W_OD_DP_AMT_CHK, W_OD_OS_AMT_CHK FROM LNODHIST L WHERE LNODHIST_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND L.LNODHIST_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM AND L.LNODHIST_EFF_DATE = (SELECT MAX(LL.LNODHIST_EFF_DATE)

503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562

FROM WHERE AND AND

LNODHIST LL LNODHIST_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE LL.LNODHIST_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM LL.LNODHIST_EFF_DATE <= W_PROCESS_DATE);

EXCEPTION WHEN NO_DATA_FOUND THEN W_OD_LIMIT_AMT_CHK := 0; W_OD_DP_AMT_CHK := 0; W_OD_OS_AMT_CHK := 0; END LNODHISTREAD;

IF ((NVL(V_LIMIT_DP_REQD, '0') = '1' AND (W_OD_DP_AMT_CHK <> W_ACTUAL_DP_AMT_CHK)) OR (W_OD_LIMIT_AMT_CHK <> W_ACTUAL_LIMIT_AMT_CHK) OR W_OD_OS_AMT_CHK <> W_CURR_BAL) THEN SP_GET_OVERDUE; END IF; END CHECK_LATEST_LIMIT;

PROCEDURE CHECK_INT_GRACE_PERIOD IS BEGIN W_LAST_INT_APPL_DATE := NULL; W_INT_GRACE_DAYS := 0; W_CHK_INT_GRACE_DATE := NULL; <<GET_MAX_APPL_DATE>> BEGIN SELECT NVL(MAX(LNINTAPPL_APPL_DATE), NULL) INTO W_LAST_INT_APPL_DATE FROM LNINTAPPL WHERE LNINTAPPL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNINTAPPL_BRN_CODE = W_BRN_CODE AND LNINTAPPL_ACNT_NUM = V_ACNTS_INTERNAL_ACNUM AND LNINTAPPL_APPL_DATE <= W_PROCESS_DATE; EXCEPTION WHEN NO_DATA_FOUND THEN W_LAST_INT_APPL_DATE := NULL; END GET_MAX_APPL_DATE; <<GET_GRACE_DAYS>> BEGIN SELECT NVL(LNPRD_INT_RECOV_GRACE_DAYS, 0) INTO W_INT_GRACE_DAYS FROM LNPRODPM WHERE LNPRD_PROD_CODE = V_ACNTS_PROD_CODE; EXCEPTION WHEN NO_DATA_FOUND THEN W_INT_GRACE_DAYS := 0; END GET_GRACE_DAYS; W_CHK_INT_GRACE_DATE := W_LAST_INT_APPL_DATE + W_INT_GRACE_DAYS; IF W_CHK_INT_GRACE_DATE IS NOT NULL AND W_LAST_OD_UPDATE_DATE IS NOT NULL THEN IF W_CHK_INT_GRACE_DATE >= W_LAST_OD_UPDATE_DATE AND W_CHK_INT_GRACE_DATE < W_PROCESS_DATE THEN

563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622

SP_GET_OVERDUE; END IF; END IF; EXCEPTION WHEN OTHERS THEN W_ERROR_MSG := 'ERROR IN CHECK_INT_GRACE_PERIOD'; RAISE E_USER_EXCEP; END CHECK_INT_GRACE_PERIOD;

PROCEDURE CHECK_MANUAL_APPLIED_INT IS BEGIN W_INT_GRACE_DAYS := 0; W_CHK_INT_GRACE_DATE := NULL; <<GET_RECOV_GRACE_DAYS>> BEGIN SELECT NVL(LNPRD_INT_RECOV_GRACE_DAYS, 0) INTO W_INT_GRACE_DAYS FROM LNPRODPM WHERE LNPRD_PROD_CODE = V_ACNTS_PROD_CODE; EXCEPTION WHEN NO_DATA_FOUND THEN W_INT_GRACE_DAYS := 0; END GET_RECOV_GRACE_DAYS; W_CHK_INT_GRACE_DATE := (W_PROCESS_DATE - W_INT_GRACE_DAYS) - 1; <<READ_TRANADV_TRAN>> BEGIN W_FIN_YEAR := SP_GETFINYEAR(PKG_ENTITY.FN_GET_ENTITY_CODE, W_PROCESS_DATE); W_COUNT := 0; W_SQL_ADV := 'SELECT COUNT(0) FROM TRANADV' || W_FIN_YEAR || ', TRAN' || W_FIN_YEAR || ' WHERE TRAN_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND TRANADV_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND TRANADV_BRN_CODE = TRAN_BRN_CODE AND TRAN_BRN_CODE = ' || W_BRN_CODE || ' AND TRAN_INTERNAL_ACNUM = ' || V_ACNTS_INTERNAL_ACNUM || ' AND TRAN_DB_CR_FLG = ''D'' AND TRAN_DATE_OF_TRAN = ' || CHR(39) || W_CHK_INT_GRACE_DATE || CHR(39) || ' AND TRANADV_DATE_OF_TRAN = TRAN_DATE_OF_TRAN AND TRANADV_BATCH_NUMBER = TRAN_BATCH_NUMBER AND TRANADV_BATCH_SL_NUM = TRAN_BATCH_SL_NUM AND TRANADV_INTRD_AC_AMT > 0'; EXECUTE IMMEDIATE W_SQL_ADV INTO W_COUNT; IF W_COUNT > 0 THEN SP_GET_OVERDUE; END IF; END READ_TRANADV_TRAN; EXCEPTION WHEN OTHERS THEN

623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 UM); 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681

W_ERROR_MSG := 'ERROR IN CHECK_MANUAL_APPLIED_INT'; RAISE E_USER_EXCEP; END CHECK_MANUAL_APPLIED_INT;

PROCEDURE READ_ACASLLDTL AS BEGIN SELECT ACASLLDTL_CLIENT_NUM, ACASLLDTL_LIMIT_LINE_NUM INTO V_ACASLL_CLINET_NUM, V_ACASLL_LIMITLINE_NUM FROM ACASLLDTL WHERE ACASLLDTL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND ACASLLDTL_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM; EXCEPTION WHEN NO_DATA_FOUND THEN V_ACASLL_CLINET_NUM := 0; V_ACASLL_LIMITLINE_NUM := 0; WHEN OTHERS THEN IF TRIM(W_ERROR_MSG) IS NULL THEN W_ERROR_MSG := 'ERROR IN READ_ACASLLDTL'; END IF; RAISE E_USER_EXCEP; END READ_ACASLLDTL; PROCEDURE CHECK_LIMIT_RENEW_REC AS V_LIMLNEHIST_EFF_DATE DATE := NULL; BEGIN READ_ACASLLDTL; <<READ_LIMITLINEHIST>> BEGIN SELECT LIMLNEHIST_EFF_DATE INTO V_LIMLNEHIST_EFF_DATE FROM LIMITLINEHIST WHERE LIMLNEHIST_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LIMLNEHIST_CLIENT_CODE = V_ACASLL_CLINET_NUM AND LIMLNEHIST_LIMIT_LINE_NUM = V_ACASLL_LIMITLINE_NUM AND LIMLNEHIST_EFF_DATE = (SELECT MAX(LH.LIMLNEHIST_EFF_DATE) FROM LIMITLINEHIST LH WHERE LH.LIMLNEHIST_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LH.LIMLNEHIST_CLIENT_CODE = V_ACASLL_CLINET_NUM AND LH.LIMLNEHIST_LIMIT_LINE_NUM = V_ACASLL_LIMITLINE_N EXCEPTION WHEN NO_DATA_FOUND THEN V_LIMLNEHIST_EFF_DATE := NULL; WHEN OTHERS THEN IF TRIM(W_ERROR_MSG) IS NULL THEN W_ERROR_MSG := 'ERROR IN READ_LIMITLINEHIST'; END IF; RAISE E_USER_EXCEP; END READ_LIMITLINEHIST; IF V_LIMLNEHIST_EFF_DATE IS IF (W_LAST_OD_UPDATE_DATE (V_LIMLNEHIST_EFF_DATE (V_LIMLNEHIST_EFF_DATE SP_GET_OVERDUE; NOT NULL THEN IS NOT NULL) AND > W_LAST_OD_UPDATE_DATE) AND <= W_PROCESS_DATE) THEN

682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 ODE 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740

END IF; END IF; EXCEPTION WHEN OTHERS THEN IF TRIM(W_ERROR_MSG) IS NULL THEN W_ERROR_MSG := 'ERROR IN CHECK_LIMIT_RENEW_REC'; END IF; RAISE E_USER_EXCEP; END CHECK_LIMIT_RENEW_REC;

PROCEDURE CHECK_REPHASEMENT IS W_LNACRS_LAT_EFF_DATE DATE := NULL; BEGIN <<READ_LNACRS>> BEGIN SELECT LNACRS_LATEST_EFF_DATE INTO W_LNACRS_LAT_EFF_DATE FROM LNACRS WHERE LNACRS_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_C AND LNACRS_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM; EXCEPTION WHEN NO_DATA_FOUND THEN W_LNACRS_LAT_EFF_DATE := NULL; END READ_LNACRS; IF (W_LNACRS_LAT_EFF_DATE > W_LAST_OD_UPDATE_DATE AND W_LNACRS_LAT_EFF_DATE <= W_PROCESS_DATE) THEN SP_GET_OVERDUE; END IF; EXCEPTION WHEN OTHERS THEN IF TRIM(W_ERROR_MSG) IS NULL THEN W_ERROR_MSG := 'ERROR IN CHECK_REPHASEMENT'; END IF; RAISE E_USER_EXCEP; END CHECK_REPHASEMENT; PROCEDURE CHECKLIMIT_PROC IS BEGIN <<READ_ACASLLDTL>> BEGIN SELECT ACASLLDTL_CLIENT_NUM, ACASLLDTL_LIMIT_LINE_NUM INTO V_ACASLL_CLINET_NUM, V_ACASLL_LIMITLINE_NUM FROM ACASLLDTL WHERE ACASLLDTL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND ACASLLDTL_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM; <<READ_LIMITLINE>> BEGIN SELECT LMTLINE_LIMIT_EXPIRY_DATE, LMTLINE_DP_REQD INTO V_LIMIT_EXPIRY_DATE, V_LIMIT_DP_REQD FROM LIMITLINE WHERE LMTLINE_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LMTLINE_CLIENT_CODE = V_ACASLL_CLINET_NUM AND LMTLINE_NUM = V_ACASLL_LIMITLINE_NUM; <<COMPARE_DATES>> BEGIN IF W_LAST_OD_UPDATE_DATE IS NOT NULL THEN

741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800

IF V_LIMIT_EXPIRY_DATE > W_LAST_OD_UPDATE_DATE AND V_LIMIT_EXPIRY_DATE <= W_PROCESS_DATE THEN SP_GET_OVERDUE; END IF; ELSE IF V_LIMIT_EXPIRY_DATE <= W_PROCESS_DATE THEN SP_GET_OVERDUE; END IF; END IF; IF V_LIMIT_EXPIRY_DATE > W_PROCESS_DATE THEN SELECT PRODUCT_FOR_RUN_ACS INTO V_PROD_FOR_RUN_ACS FROM PRODUCTS WHERE PRODUCT_CODE = V_ACNTS_PROD_CODE; IF (V_LIMIT_DP_REQD = '1' AND V_PROD_FOR_RUN_ACS = '1') THEN SP_CHECK_DP; ELSE IF V_PROD_FOR_RUN_ACS <> '1' THEN SP_CHECK_REPAY_DATE; END IF; END IF; END IF;

IF W_OD_CALC_FLG = 0 THEN CHECK_LATEST_LIMIT; END IF; IF W_OD_CALC_FLG = 0 THEN CHECK_INT_GRACE_PERIOD; END IF; IF W_OD_CALC_FLG = 0 THEN CHECK_MANUAL_APPLIED_INT; END IF; IF W_OD_CALC_FLG = 0 THEN CHECK_LIMIT_RENEW_REC; END IF; IF (W_OD_CALC_FLG = 0 AND W_PRODUCT_FOR_RUN_ACS <> '1') THEN CHECK_REPHASEMENT; END IF; EXCEPTION WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN

801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860

W_ERROR_MSG := 'ERROR IN COMPARE_DATES'; END IF; RAISE E_USER_EXCEP; END COMPARE_DATES; EXCEPTION WHEN NO_DATA_FOUND THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := ''; END IF; WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN READ_LIMITLINE'; END IF; RAISE E_USER_EXCEP; END READ_LIMITLINE; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN READ_ACASLLDTL'; END IF; RAISE E_USER_EXCEP; END READ_ACASLLDTL; END CHECKLIMIT_PROC; PROCEDURE SP_CHECK_DP IS BEGIN SELECT LNDP_DP_VALID_UPTO_DATE INTO V_LNDP_DP_VALID_UPTO_DATE FROM LNDP WHERE LNDP_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNDP_CLIENT_NUM = V_ACASLL_CLINET_NUM AND LNDP_LIMIT_NUM = V_ACASLL_LIMITLINE_NUM; IF W_LAST_OD_UPDATE_DATE IS NOT NULL THEN IF (V_LNDP_DP_VALID_UPTO_DATE > W_LAST_OD_UPDATE_DATE AND V_LIMIT_EXPIRY_DATE <= W_PROCESS_DATE) THEN SP_GET_OVERDUE; END IF; ELSE IF (V_LNDP_DP_VALID_UPTO_DATE <= W_PROCESS_DATE) THEN SP_GET_OVERDUE; END IF; END IF; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN SP_CHECK_DP'; END IF; RAISE E_USER_EXCEP; END SP_CHECK_DP; PROCEDURE SP_CHECK_REPAY_DATE IS BEGIN W_EXIT := 0; W_PROC_OD := 0; <<FETCH_LNACRSDTL>> BEGIN DECLARE CURSOR D_TMPLNACRSDTL IS

861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920

SELECT LNACRSDTL_REPAY_AMT, LNACRSDTL_REPAY_FROM_DATE, LNACRSDTL_REPAY_FREQ, LNACRSDTL_NUM_OF_INSTALLMENT FROM LNACRSDTL WHERE LNACRSDTL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNACRSDTL_INTERNAL_ACNUM = V_ACNTS_INTERNAL_ACNUM; D_LNACRS D_TMPLNACRSDTL%ROWTYPE; BEGIN WHILE (W_EXIT = 0) LOOP FOR D_LNACRS IN D_TMPLNACRSDTL LOOP W_REPAY_DATE := D_LNACRS.LNACRSDTL_REPAY_FROM_DATE; W_REPAY_FREQ := D_LNACRS.LNACRSDTL_REPAY_FREQ; W_REPAY_AMT := D_LNACRS.LNACRSDTL_REPAY_AMT; W_NOF_INSTALL := D_LNACRS.LNACRSDTL_NUM_OF_INSTALLMENT; SP_GET_REPAY_DATE; END LOOP; END LOOP; IF (W_PROC_OD = '1') THEN SP_GET_OVERDUE; END IF; END; END FETCH_LNACRSDTL; EXCEPTION WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN SP_CHECK_REPAY_DATE'; END IF; RAISE E_USER_EXCEP; END SP_CHECK_REPAY_DATE; PROCEDURE SP_GET_REPAY_DATE IS BEGIN W_EXIT_SUB := 0; WHILE (W_EXIT_SUB = 0) LOOP SP_GET_REPAY_DATE_SUB; END LOOP; EXCEPTION WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN SP_GET_REPAY_DATE'; END IF; RAISE E_USER_EXCEP; END SP_GET_REPAY_DATE; PROCEDURE SP_GET_REPAY_DATE_SUB IS BEGIN IF W_LAST_OD_UPDATE_DATE IS NOT NULL THEN IF (W_REPAY_DATE > W_LAST_OD_UPDATE_DATE AND W_REPAY_DATE <= W_PROCESS_DATE) THEN W_PROC_OD := '1'; W_EXIT := '1'; W_EXIT_SUB := '1'; END IF; ELSE IF W_REPAY_DATE <= W_PROCESS_DATE THEN W_PROC_OD := '1'; W_EXIT := '1'; W_EXIT_SUB := '1'; END IF; END IF; IF W_REPAY_DATE > W_PROCESS_DATE THEN

921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980

W_EXIT := '1'; W_EXIT_SUB := '1'; END IF; W_NOF_INSTALL := W_NOF_INSTALL - 1; IF (W_REPAY_FREQ = 'M') THEN W_REPAY_DATE := ADD_MONTHS(W_REPAY_DATE, 1); ELSE IF (W_REPAY_FREQ = 'Q') THEN W_REPAY_DATE := ADD_MONTHS(W_REPAY_DATE, 3); ELSE IF (W_REPAY_FREQ = 'H') THEN W_REPAY_DATE := ADD_MONTHS(W_REPAY_DATE, 6); ELSE IF (W_REPAY_FREQ = 'Y') THEN W_REPAY_DATE := ADD_MONTHS(W_REPAY_DATE, 12); ELSE IF (W_REPAY_FREQ = 'X') THEN W_EXIT_SUB := 1; W_EXIT := 1; END IF; END IF; END IF; END IF; END IF; IF (W_NOF_INSTALL = 0) THEN W_EXIT_SUB := 1; W_EXIT := 1; END IF; EXCEPTION WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN SP_GET_REPAY_DATE_SUB'; END IF; RAISE E_USER_EXCEP; END SP_GET_REPAY_DATE_SUB; PROCEDURE CHECK_INPUTS IS BEGIN W_IN_BRANCH_CODE := 0; IF NVL(P_BRN_CODE, 0) <> 0 THEN W_IN_BRANCH_CODE := P_BRN_CODE; END IF;

IF (P_PROCESS_DATE IS NULL) THEN W_PROCESS_DATE := PKG_EODSOD_FLAGS.PV_CURRENT_DATE; ELSE W_PROCESS_DATE := TO_DATE(P_PROCESS_DATE, 'DD-MM-YYYY'); END IF; IF (P_CURR_BUS_DATE IS NULL) THEN W_CURR_BUS_DATE := PKG_EODSOD_FLAGS.PV_CURRENT_DATE; ELSE W_CURR_BUS_DATE := TO_DATE(P_CURR_BUS_DATE, 'DD-MM-YYYY'); END IF; IF (P_CURR_BUS_DATE IS NULL) THEN W_CBD := PKG_EODSOD_FLAGS.PV_CURRENT_DATE; ELSE W_CBD := TO_DATE(P_CURR_BUS_DATE, 'DD-MM-YYYY'); END IF;

981 IF (P_SESS_USER_ID IS NULL) THEN 982 V_SESS_USER_ID := PKG_EODSOD_FLAGS.PV_USER_ID; 983 ELSE 984 V_SESS_USER_ID := P_SESS_USER_ID; 985 END IF; 986 987 IF (W_PROCESS_DATE IS NULL) THEN 988 W_ERROR_MSG := 'PROCESS DATE IS NOT SPECIFIED'; 989 RAISE E_USER_EXCEP; 990 END IF; 991 IF (W_CURR_BUS_DATE IS NULL) THEN 992 W_ERROR_MSG := 'CURRENT BUSINESS DATE IS NOT SPECIFIED'; 993 RAISE E_USER_EXCEP; 994 END IF; 995 IF (V_SESS_USER_ID IS NULL) THEN 996 W_ERROR_MSG := 'USER ID IS NOT SPECIFIED'; 997 RAISE E_USER_EXCEP; 998 END IF; 999 EXCEPTION 1000 WHEN OTHERS THEN 1001 W_ERROR_MSG := 'ERROR IN CHECK_INPUTS'; 1002 RAISE E_USER_EXCEP; 1003 END CHECK_INPUTS; 1004 1005 PROCEDURE FETCH_LOANACNTS IS 1006 BEGIN 1007 <<READ_ACNTS>> 1008 1009 BEGIN 1010 1011 1012 1013 1014 1015 1016 1017 1018 W_SQL := 'SELECT ACNTS_INTERNAL_ACNUM,ACNTS_BRN_CODE,ACNTS_PROD_CO DE,ACNTS_CURR_CODE, 1019 ACNTS_OPENING_DATE,TRUNC(LNACNT_ENTD_ON) LNACNT _ENTD_ON, 1020 PRODUCT_FOR_RUN_ACS FROM LNPRODPM, ACNTS,LOANA CNTS,PRODUCTS WHERE LNACNT_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND ACNTS_ ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE 1021 AND ACNTS_PROD_CODE = PRODUCT_CODE AND 1022 (ACNTS_CLOSURE_DATE IS NULL OR ACNTS_CLOSURE_ DATE > ' || CHR(39) || W_CBD || CHR(39) || ') 1023 AND ACNTS_INTERNAL_ACNUM = LNACNT_INTERNAL_ACNU M 1024 AND ACNTS_AUTH_ON IS NOT NULL AND ACNTS_PROD_CO DE = LNPRD_PROD_CODE AND LNPRD_INT_APPL_FREQ <> ''I'' '; 1025 1026 IF (W_BRN_CODE > 0) THEN 1027 W_SQL := W_SQL || ' AND ACNTS_BRN_CODE =' || W_BRN_CODE; 1028 END IF; 1029 W_SQL := W_SQL || ' ORDER BY ACNTS_INTERNAL_ACNUM'; 1030 EXECUTE IMMEDIATE W_SQL BULK COLLECT 1031 INTO IDX_REC_ACNTS; 1032 IF IDX_REC_ACNTS.FIRST IS NOT NULL THEN 1033 FOR J IN IDX_REC_ACNTS.FIRST .. IDX_REC_ACNTS.LAST LOOP

1034 V_ACNTS_INTERNAL_ACNUM := IDX_REC_ACNTS(J).V_INTERNAL_ACNUM; 1035 V_ACNTS_PROD_CODE := IDX_REC_ACNTS(J).V_PROD_CODE; 1036 W_ACNT_BRN_CODE := IDX_REC_ACNTS(J).V_ACNT_BRN_CODE; 1037 V_ACNTS_CURR_CODE := IDX_REC_ACNTS(J).V_CURR_CODE; 1038 W_OPENING_DATE := IDX_REC_ACNTS(J).V_OPENING_DATE; 1039 W_ENTD_ON := IDX_REC_ACNTS(J).V_ENTD_ON; 1040 W_PRODUCT_FOR_RUN_ACS := IDX_REC_ACNTS(J).V_PRODUCT_FOR_RUN_A CS; 1041 W_LAST_OD_UPDATE_DATE := L_LAST_OD_UPDATE_DATE; 1042 1043 1044 W_OD_CALC_FLG := 0; 1045 IF PKG_PROCESS_CHECK.FN_IGNORE_ACNUM(PKG_ENTITY.FN_GET_ENTITY_ CODE, 1046 V_ACNTS_INTERNAL_ACNUM) = 1047 FALSE THEN 1048 IF (W_LAST_OD_UPDATE_DATE) IS NOT NULL THEN 1049 IF (W_LAST_OD_UPDATE_DATE <> W_CBD) THEN 1050 W_DAYS := W_CBD - W_LAST_OD_UPDATE_DATE; 1051 W_PROCESS_DATE := W_LAST_OD_UPDATE_DATE; 1052 IF (W_DAYS > 0) THEN 1053 WHILE (W_PROCESS_DATE + 1 <= W_CBD) LOOP 1054 W_PROCESS_DATE := W_PROCESS_DATE + 1; 1055 FETCH_TRAN; 1056 W_LAST_OD_UPDATE_DATE := W_LAST_OD_UPDATE_DATE + 1; 1057 END LOOP; 1058 END IF; 1059 END IF; 1060 ELSE 1061 FETCH_TRAN; 1062 END IF; 1063 END IF; 1064 END LOOP; 1065 END IF; 1066 EXCEPTION 1067 WHEN OTHERS THEN 1068 IF TRIM(W_ERROR_MSG) IS NULL THEN 1069 W_ERROR_MSG := 'Error in FETCH_LOANACNTS ' || 1070 SUBSTR(SQLERRM, 1, 700); 1071 END IF; 1072 W_ERROR_MSG := FACNO(PKG_ENTITY.FN_GET_ENTITY_ CODE, 1073 V_ACNTS_INTERNAL_ACNUM) | | ' ' || 1074 W_ERROR_MSG; 1075 PKG_EODSOD_FLAGS.PV_ERROR_MSG := W_ERROR_MSG; 1076 END READ_ACNTS; 1077 END FETCH_LOANACNTS; 1078 1079 PROCEDURE FETCH_TRAN IS 1080 BEGIN 1081 IF (W_OPENING_DATE <= W_PROCESS_DATE AND W_ENTD_ON <= W_PROCESS_DATE ) THEN 1082 W_FIN_YEAR := SP_GETFINYEAR(PKG_ENTITY.FN_GET_ENTITY_CODE, 1083 W_PROCESS_DATE); 1084 W_SQL_OD := 'SELECT /*+ INDEX(TR,IDX_T' || W_FIN_YEAR || 1085 '_TRVALUE)*/ COUNT(1) FROM TRAN' || W_FIN_YEAR || 1086 ' TR WHERE TRAN_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTIT Y_CODE AND TRAN_INTERNAL_ACNUM =' || 1087 V_ACNTS_INTERNAL_ACNUM ||

1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147

' AND TRAN_DATE_OF_TRAN = ' || CHR(39) || W_PROCESS_DATE || CHR(39) || ' AND TRAN_AUTH_ON IS NOT NULL AND TRAN_AMOUNT > 0'; EXECUTE IMMEDIATE W_SQL_OD INTO W_COUNT; <<READLNINTAPPL>> BEGIN IF NVL(W_COUNT, 0) = 0 THEN SELECT COUNT(1) INTO W_COUNT FROM LNINTAPPL C WHERE C.LNINTAPPL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND C.LNINTAPPL_BRN_CODE = W_ACNT_BRN_CODE AND C.LNINTAPPL_ACNT_NUM = V_ACNTS_INTERNAL_ACNUM AND C.LNINTAPPL_APPL_DATE = W_PROCESS_DATE - 1; END IF; EXCEPTION WHEN OTHERS THEN NULL; END READLNINTAPPL;

IF (W_COUNT > 0 OR W_LAST_OD_UPDATE_DATE IS NULL) THEN SP_GET_OVERDUE; ELSE CHECKLIMIT_PROC; END IF;

END IF; EXCEPTION WHEN OTHERS THEN IF (W_ERROR_MSG IS NULL) THEN W_ERROR_MSG := 'ERROR IN FETCH_TRAN'; END IF; RAISE E_USER_EXCEP; END FETCH_TRAN; PROCEDURE DESTROY_ARRAYS IS BEGIN IDX_REC_ACNTS.DELETE; PKG_PROCESS_CHECK.DESTROY_BRN_WISE(PKG_ENTITY.FN_GET_ENTITY_CODE); END DESTROY_ARRAYS; BEGIN PKG_ENTITY.SP_SET_ENTITY_CODE(V_ENTITY_NUM); <<START_PROCEDURE>> BEGIN INIT_PARA; CHECK_INPUTS;

1148 <<READ_LNODCNTL>> 1149 BEGIN 1150 W_SQL_OD := 'SELECT LNODCNTL_LAST_PROC_DATE FROM LNODCNTL WHERE LN ODCNTL_ENTITY_NUM = PKG_ENTITY.FN_GET_ENTITY_CODE AND LNODCNTL_NUM = 1'; 1151 EXECUTE IMMEDIATE W_SQL_OD 1152 INTO L_LAST_OD_UPDATE_DATE; 1153 EXCEPTION 1154 WHEN NO_DATA_FOUND THEN 1155 L_LAST_OD_UPDATE_DATE := NULL; 1156 WHEN OTHERS THEN 1157 W_ERROR_MSG := 'ERROR IN READ_LNODCNTL'; 1158 RAISE E_USER_EXCEP; 1159 END READ_LNODCNTL; 1160 1161 1162 1163 1164 PKG_PROCESS_CHECK.INIT_PROC_BRN_WISE(PKG_ENTITY.FN_GET_ENTITY_CODE, 1165 W_IN_BRANCH_CODE); 1166 1167 FOR IDX IN 1 .. PKG_PROCESS_CHECK.V_ACNTBRN.COUNT LOOP 1168 W_BRN_CODE := PKG_PROCESS_CHECK.V_ACNTBRN(IDX).LN_BRN_CODE; 1169 IF PKG_PROCESS_CHECK.CHK_BRN_ALREADY_PROCESSED(PKG_ENTITY.FN_GET_E NTITY_CODE, 1170 W_BRN_CODE) = FALSE THEN 1171 1172 FETCH_LOANACNTS; 1173 1174 IF TRIM(PKG_EODSOD_FLAGS.PV_ERROR_MSG) IS NULL THEN 1175 PKG_PROCESS_CHECK.INSERT_ROW_INTO_EODSODPROCBRN(PKG_ENTITY.FN_ GET_ENTITY_CODE, 1176 W_BRN_CODE); 1177 END IF; 1178 1179 PKG_PROCESS_CHECK.CHECK_COMMIT_ROLLBACK_STATUS(PKG_ENTITY.FN_GET _ENTITY_CODE); 1180 END IF; 1181 END LOOP; 1182 1183 DESTROY_ARRAYS; 1184 1185 EXCEPTION 1186 WHEN OTHERS THEN 1187 IF TRIM(W_ERROR_MSG) IS NULL THEN 1188 W_ERROR_MSG := 'Error in SP_LNODUPDATE ' || 1189 SUBSTR(SQLERRM, 1, 700); 1190 END IF; 1191 PKG_EODSOD_FLAGS.PV_ERROR_MSG := W_ERROR_MSG; 1192 PKG_PB_GLOBAL.DETAIL_ERRLOG(PKG_ENTITY.FN_GET_ENTITY_CODE, 1193 'E', 1194 PKG_EODSOD_FLAGS.PV_ERROR_MSG, 1195 ' ', 1196 0); 1197 DESTROY_ARRAYS; 1198 END START_PROCEDURE; 1199 1200 1201 1202 IF (TRIM(PKG_EODSOD_FLAGS.PV_ERROR_MSG) IS NULL) THEN

1203 1204 IF NVL(W_IN_BRANCH_CODE, 0) = 0 THEN 1205 1206 UPDATE_LNODCNTL; 1207 END IF; 1208 END IF; 1209 1210 1211 END SP_LNODUPDATE; 1212 1213 END PKG_LNODUPDATE;