标签:
CREATE OR REPLACE PACKAGE BODY PKG_ZHGL AS --账户管理包 code szn 20110829 --账户管理服务包 --定义本包中需要引用到的常量 --定义说明:定义变量时,同一个字典项的代码要集中放在一起,方便后续维护。增加新的常量时,请先确认该常量在包头是 --否已定义,避免同一个常量重复定义的情况。 C_PKG_NAME CONSTANT VARCHAR2(20) := ‘PKG_ZHGL.‘; C_CAE178_SR CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘SR‘); --收支标志.BXGX C_CAE178_ZC CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘ZC‘); --收支标志.BXGX C_AAE341_ZCJF CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCJF‘); --筹资项目.正常缴费 C_AAE341_ZHONGYANG CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZHONGYANG‘); --筹资项目.中央财政 C_AAE341_CANL CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘CANL‘); --筹资项目.残联 C_AAE341_MZ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘MZ‘); --筹资项目.民政 C_AAE341_SHENG CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘SHENG‘); --筹资项目.省财政 C_AAE341_SHI CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘SHI‘); --筹资项目.市财政 C_AAE341_ZCZ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCZ‘); --筹资项目.镇财政 C_AAE341_XIAN CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘XIAN‘); --筹资项目.县财政 C_AAE341_ZICHOU CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZICHOU‘); --筹资项目.自筹 C_AAE341_FPCSFD CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘FPCSFD‘); --筹资项目.扶贫村市分担 C_AAE341_FPCZFD CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘FPCZFD‘); --筹资项目.扶贫村镇分担 C_CAE682_YLSJ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘YLSJ‘); --数据类型.一类数据 C_CAE682_ELSJ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘ELSJ‘); --数据类型.二类数据 C_CAE230_DSDZ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘DSDZ‘); --帐户变动类型.地税到账 C_CAE230_NBZJG CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NBZJG‘); --帐户变动类型.农保转机关 C_CAE230_JGZNB CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘JGZNB‘); --帐户变动类型.机关转农保 C_CAE230_SWZRDZ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRDZ‘); --帐户变动类型.市外转入到账 C_CAE230_SWZRZYIL CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZYIL‘); --帐户变动类型.市外转入转医疗 C_CAE230_SWZRZJG CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZJG‘); --帐户变动类型.市外转入转机关 C_CAE230_SWZRZSY CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZSY‘); --帐户变动类型.市外转入转失业 C_CAE230_SWZRZST CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZST‘); --帐户变动类型.市外转入转视同 C_CAE230_SWZRZDFXYL CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZDFXYL‘); --帐户变动类型.市外转入转地方养老 C_CAE230_SWZRZGRZH CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZGRZH‘); --帐户变动类型.市外转入转个人账户 C_CAE230_ZCSWNBDZ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘ZCSWNBDZ‘); --帐户变动类型.转出市外农保到账 C_CAE230_ARSZDBL CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘ARSZDBL‘); --帐户变动类型.按人数征收补录 C_CAE230_DYZF CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘DYZF‘); --帐户变动类型.待遇支付 C_CAE230_DYZFHT CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘DYZFHT‘); --帐户变动类型.待遇支付退回 C_CAE230_NDJX CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NDJX‘); --帐户变动类型.年度计息 C_CAE230_NZJX CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NZJX‘); --帐户变动类型.年中计息 C_CAE230_LSWH CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘LSWH‘); --帐户变动类型.历史维护 C_CAE230_KXZTZ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘KXZTZ‘); --帐户变动类型.跨险种账户调整 C_CAE230_RYHB CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘RYHB‘); --帐户变动类型.人员合并 C_CAE230_SRTK CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SRTK‘); --帐户变动类型.收入退款 C_CAE230_QYZJG CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘QYZJG‘); --帐户变动类型.企业转机关 C_CAE230_JGZQY CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘JGZQY‘); --帐户变动类型.机关转企业 C_CAE230_QYZNB CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘QYZNB‘); --帐户变动类型.企业转农保 C_CAE230_NBZQY CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NBZQY‘); --帐户变动类型.农保转企业 C_CAE230_ZCSW CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘ZCSW‘); --帐户变动类型.跨统筹区转出 C_CAE320_SWZRJX CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRJX‘); --帐户变动类型.市外转入计息 C_CAE171_DBP CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE171‘, ‘DBP‘); --报盘状态.待报盘 C_BCE326_QX CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘BCE326‘, ‘QX‘); --审批标志.取消 C_BCE326_HT CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘BCE326‘, ‘HT‘); --审批标志.回退 C_CAE009_ZC CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE009‘, ‘ZC‘); C_CAA034_BJS CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘BJS‘); C_CAE177_QT CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE177‘, ‘QT‘); --收支方式.其它 C_CAE177_YHZCHZ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘CAE177‘, ‘YHZCHZ‘); --收支方式.银行正常划拨 C_BCE094_YJ CONSTANT VARCHAR2(6) := PKG_FUN.F_GET_DICT(‘BCE094‘, ‘YJ‘); --缴费标志.已缴 ---根据传入的险种类型查询险种设置表 PROCEDURE XZSZ_JLZHBZ(PI_AAE140 IN VARCHAR2, --险种类型 PO_AAA008 OUT VARCHAR2, --帐户建立标志 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS BEGIN SELECT AAA008 INTO PO_AAA008 FROM AA08 WHERE AAE140 = PI_AAE140; PO_FHZ := ‘1‘; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘XZSZ_JLZHBZ_99‘; PO_MSG := ‘调用"PKG_ZHGL.XZSZ_JLZHBZ"时找不到数据,传入参数为:‘ || ‘pi_aae140:‘ || PI_AAE140; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.XZSZ_JLZHBZ_00‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.XZSZ_JLZHBZ"时系统错误,传入参数为:‘ || ‘pi_aae140:‘ || PI_AAE140 || ‘系统错误信息是:‘ || SQLERRM || ‘;调用栈是:‘ || DBMS_UTILITY.FORMAT_CALL_STACK || ‘。‘; END XZSZ_JLZHBZ; ---根据险种类型的不同分别调用不同的帐户生成方法生成个人帐户 PROCEDURE ZHGL_GRZHSC(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_AAA008 VARCHAR2(6); --账户建立标志 V_ZHJLBZ_S VARCHAR2(6); --综合参数常量 BEGIN --调用险种帐户建立标志(XZSZ_JLZHBZ)确定建立帐户标志v_jlzhbz PO_FHZ := ‘1‘; XZSZ_JLZHBZ(PI_AAE140, V_AAA008, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_ZHJLBZ_S := PKG_FUN.F_GET_DICT(‘AAA008‘, ‘Y‘); --获取账户建立标志:是 IF V_AAA008 = V_ZHJLBZ_S THEN --如果是医疗险种 IF SUBSTR(PI_AAE140, 1, 1) = ‘3‘ THEN --调用医保个人帐户生成方法(YBGRZH_SC)生成医保个人帐户 YBGRZH_SC(PI_AAC001, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; ELSE --养老险种 --调用养老个人帐户生成方法(YLGRZH_SC)生成养老个人帐户 YLGRZH_SC(PI_AAC001, PI_AAE140, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; END IF; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.ZHGL_GRZHSC_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ZHGL_GRZHSC"时系统错误,传入参数为:‘ || ‘pi_aae140:‘ || PI_AAE140 || ‘,pi_aac001:‘ || PI_AAC001 || ‘,系统错误信息是:‘ || SQLERRM || ‘;调用栈是:‘ || DBMS_UTILITY.FORMAT_CALL_STACK || ‘。‘; END ZHGL_GRZHSC; ---判断养老个人帐户是否存在,存在则不处理,不存在则生成养老个人帐户记录 PROCEDURE YLGRZH_SC(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_CAE246 SIC81.CAE246%TYPE; --养老个人账户状态 V_ZHZT_ZC SIC81.CAE246%TYPE; V_AC01 AC01%ROWTYPE; --个人基本资料表 V_XYYH VARCHAR2(8); --下月一号 BEGIN -- 查询个人基本资料 PKG_PUB.GRJBZL_CX(PI_AAC001, V_AC01, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; -- 查询审核年月.下月 PKG_PUB.GETSHNYXY(V_AC01.BAE001, V_XYYH, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --获取账户状态_正常综合参数 V_ZHZT_ZC := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZC‘); --获取账户建立标志:是 IF PO_FHZ != ‘1‘ THEN RETURN; END IF; -- 判断养老个人帐户是否存在 BEGIN SELECT CAE246 INTO V_CAE246 FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO SIC81 (BAE001, AAC001, AAB001, AAE140, CAE246, AAE206, CAE124) SELECT BAE001, PI_AAC001, AAB001, PI_AAE140, V_ZHZT_ZC, TO_NUMBER(V_XYYH || ‘01‘), (TO_NUMBER(SUBSTRB(V_XYYH, 1, 4)) - 1) || ‘1231‘ FROM AC01 WHERE AAC001 = PI_AAC001; IF SQL%NOTFOUND THEN PO_FHZ := ‘ZHGL_YlGRZH_SC_01‘; PO_MSG := ‘生成养老个人帐户时出现系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; RETURN; END IF; END; --目前东莞程序没有对账户状态_注销的做处理。 PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘ZHGL_YLGRZH_SC_99‘; PO_MSG := ‘个人顺序号为‘ || TO_CHAR(PI_AAC001) || ‘的基本资料不存在‘; RETURN; END YLGRZH_SC; ---获取养老个人账户.行记录 PROCEDURE YLGRZH_CX(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PO_SIC81 OUT SIC81%ROWTYPE, --养老账户行记录 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_PROCNAME VARCHAR2(50) := C_PKG_NAME || ‘ylgrzh_cx‘; V_PARAMS VARCHAR2(1000); BEGIN V_PARAMS := ‘入参为:‘ || ‘pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140; SELECT * INTO PO_SIC81 FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; PO_FHZ := ‘1‘; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := V_PROCNAME || ‘_100‘; PO_MSG := ‘对应参保人的养老账户信息不存在。‘ || V_PARAMS; RETURN; WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PARAMS); RETURN; END YLGRZH_CX; ---判断医保个人帐户是否存在,存在则不处理,不存在则生成医保个人帐户记录 PROCEDURE YBGRZH_SC(PI_AAC001 IN NUMBER, --个人id PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_CAE246 SKC81.CAE246%TYPE; --账户状态 V_ZHZT_ZC SKC81.CAE246%TYPE; --账户状态常量账户状态_正常 BEGIN --获取账户状态_正常综合参数 V_ZHZT_ZC := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZC‘); --获取账户建立标志:是 BEGIN SELECT CAE246 INTO V_CAE246 FROM SKC81 WHERE AAC001 = PI_AAC001; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO SKC81 (BAE001, AAB001, AAC001, CAE246) SELECT BAE001, AAB001, AAC001, V_ZHZT_ZC FROM AC01 WHERE AAC001 = PI_AAC001; IF SQL%NOTFOUND THEN PO_FHZ := ‘ZHGL_YBGRZH_SC_01‘; PO_MSG := ‘个人顺序号为‘ || TO_CHAR(PI_AAC001) || ‘的基本资料不存在‘; RETURN; END IF; END; --目前东莞程序没有对账户状态_注销的做处理。 PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘ZHGL_YBGRZH_SC_99‘; PO_MSG := ‘生成医保个人帐户时出现系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; RETURN; END YBGRZH_SC; ---根据入参险种类型判断是医疗险种还是养老险种,并调用对应修改账户状态方法 PROCEDURE ZHGL_XGZHZT(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_CAE246 IN VARCHAR2, --帐户状态 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS BEGIN IF SUBSTR(PI_AAE140, 1, 1) = ‘3‘ THEN -- 医保个人帐户.修改帐户状态 YBGRZH_XGZHZT(PI_AAC001, PI_CAE246, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; ELSE -- 养老个人帐户.修改帐户状态 YLGRZH_XGZHZT(PI_AAC001, PI_AAE140, PI_CAE246, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘ZHGL_XGZHZT_99‘; PO_MSG := ‘修改帐户状态时出现系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END ZHGL_XGZHZT; ---根据人员ID和险种类型修改对应记录的帐户状态为入参值 PROCEDURE YLGRZH_XGZHZT(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_CAE246 IN VARCHAR2, --帐户状态 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS BEGIN --同步养老个人账户 UPDATE SIC81 SET CAE246 = NVL(PI_CAE246, CAE246) --入参为空,不改变状态 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; --并同步养老视同账户 UPDATE SIC82 SET CAE246 = NVL(PI_CAE246, CAE246) --入参为空,不改变状态 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; PO_FHZ := ‘1‘; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘ZHGL_XGZHZT_99‘; PO_MSG := ‘修改养老个人帐户的状态时出现系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YLGRZH_XGZHZT; --根据人员ID修改对应记录的帐户状态为入参值 PROCEDURE YBGRZH_XGZHZT(PI_AAC001 IN NUMBER, --人员ID PI_CAE246 IN VARCHAR2, --帐户状态 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS BEGIN UPDATE SKC81 SET CAE246 = NVL(PI_CAE246, CAE246) --入参为空,不改变状态 WHERE AAC001 = PI_AAC001; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘ZHGL_20299‘; PO_MSG := ‘修改医保个人帐户状态时出现系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YBGRZH_XGZHZT; --账户管理_账户注销 PROCEDURE ZHGL_ZHZX(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_BAE007 IN VARCHAR2, --业务流水号 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_AAC008 AC02.AAC008%TYPE; --人员参保资料中 V_GRCBZT_ZZCB AC02.AAC008%TYPE; --综合参数_个人参保状态_终止参保 V_ZHZT_ZX SIC81.CAE246%TYPE; --综合参数_账户状态_注销 BEGIN PO_FHZ := ‘1‘; --判断险种是否已经参保,如果不存在参保信息则不允许注销,如果存在参保信息但是参保状态为终止参保也不能办理注销 BEGIN SELECT AAC008 INTO V_AAC008 FROM AC02 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL.ZHGL_ZHZX_01‘; PO_MSG := ‘个人顺序号为:‘ || PI_AAC001 || ‘人员未参加类型为‘ || PI_AAE140 || ‘的险种,不需要办理帐户注销!‘; RETURN; END; V_GRCBZT_ZZCB := PKG_FUN.F_GET_DICT(‘AAC008‘, ‘ZZCB‘); --获取账户建立标志:是 V_ZHZT_ZX := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZX‘); --获取账户状态_注销 IF V_AAC008 != V_GRCBZT_ZZCB THEN PO_FHZ := ‘PKG_ZHGL.ZHGL_ZHZX_02‘; PO_MSG := ‘个人顺序号为:‘ || PI_AAC001 || ‘人员的险种类型为‘ || PI_AAE140 || ‘的险种参保状态不是终止参保,不能办理帐户注销,请先办理退保!‘; RETURN; END IF; --调用帐户管理-修改帐户状态方法(ZHGL_XGZHZT)修改帐户状态为注销 PKG_ZHGL.ZHGL_XGZHZT(PI_AAC001, PI_AAE140, V_ZHZT_ZX, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; -- 调用帐户管理-帐户备份方法(ZHGL_GRZHBF)生成帐户备份记录 PKG_ZHGL.ZHGL_GRZHBF(PI_AAC001, PI_AAE140, PI_BAE007, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.ZHGL_ZHZX_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ZHGL_ZHZX"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END ZHGL_ZHZX; --根据险种类型不同调用不同的处理方法备份个人帐户信息,包括养老个人账户,医保个人账户 PROCEDURE ZHGL_GRZHBF(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_BAE007 IN VARCHAR2, --业务流水号 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS BEGIN PO_FHZ := ‘1‘; IF SUBSTR(PI_AAE140, 1, 1) = ‘3‘ THEN --医疗险种 --险种类型为医疗则调用ybgrzh_bf方法处理 PKG_ZHGL.YBGRZH_BF(PI_AAC001, PI_BAE007, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; ELSIF SUBSTR(PI_AAE140, 1, 1) = ‘1‘ THEN --险种类型为养老则调用ylgrzh_bf方法处理 PKG_ZHGL.YLGRZH_BF(PI_AAC001, PI_AAE140, PI_BAE007, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.zhgl_grzhbf_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.zhgl_grzhbf"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END ZHGL_GRZHBF; --根据人员ID与险种类型生成养老个人帐户备份记录(SAE22) PROCEDURE YLGRZH_BF(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_BAE007 IN VARCHAR2, --业务流水号 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS BEGIN PO_FHZ := ‘1‘; --前面部分全字段相同,仅最后两个字段不同 INSERT INTO SAE22 (BAE001, AAB001, AAC001, AAE140, CAE246, AAE262, AAE264, AAE263, AAE265, AAE253, AAE254, AAE256, AAE257, CAC046, CAC047, AAE206, CAC048, CAC052, CAC053, CAC054, CAC055, CAC056, CAC057, CAC058, CAC059, CAC060, CAC061, CAC062, CAC063, CAC064, CAC065, CAC066, CAC067, CAC068, CAC069, CAC070, CAC071, CAC072, CAC073, CAE837, BFE229) SELECT BAE001, AAB001, AAC001, AAE140, CAE246, AAE262, AAE264, AAE263, AAE265, AAE253, AAE254, AAE256, AAE257, CAC046, CAC047, AAE206, CAC048, CAC052, CAC053, CAC054, CAC055, CAC056, CAC057, CAC058, CAC059, CAC060, CAC061, CAC062, CAC063, CAC064, CAC065, CAC066, CAC067, CAC068, CAC069, CAC070, CAC071, CAC072, CAC073, PI_BAE007, ‘‘ FROM SIC81 A WHERE A.AAC001 = PI_AAC001; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.ylgrzh_bf_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ylgrzh_bf"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END YLGRZH_BF; --根据人员ID生成养医保人帐户备份记录(SAE24); PROCEDURE YBGRZH_BF(PI_AAC001 IN NUMBER, --人员ID PI_BAE007 IN VARCHAR2, --业务流水号 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS BEGIN --前面部分全字段相同,仅最后两个字段不同 INSERT INTO SAE24 (BAE001, AAB001, AAC001, CAE246, AAE252, CAC078, CAC079, AAE262, AAE264, CAC080, AAE240, AAE013, CAE837, BFE229) SELECT BAE001, AAB001, AAC001, CAE246, AAE252, CAC078, CAC079, AAE262, AAE264, CAC080, AAE240, AAE013, PI_BAE007, ‘‘ FROM SKC81 WHERE AAC001 = PI_AAC001; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.ybgrzh_bf_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ybgrzh_bf"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_bae007:‘ || PI_BAE007 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END YBGRZH_BF; --养老账户变更明细_生成 PROCEDURE YLZHBGMX_SC(PI_SIC83 IN SIC83%ROWTYPE, --养老保险变更明细行记录 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_SIC83 SIC83%ROWTYPE; --账户变更明细表 V_CAC074 SIC83.CAC074%TYPE; V_CAC075 SIC83.CAC075%TYPE; V_CAC076 SIC83.CAC076%TYPE; V_CAC077 SIC83.CAC077%TYPE; BEGIN PO_FHZ := ‘1‘; V_SIC83 := PI_SIC83; --调用序列发生器SEQ_BXGX_CAE176生成帐户变更顺序号,并赋值给v_zhbgmx SELECT SEQ_BXGX_CAE176.NEXTVAL INTO V_SIC83.CAE176 FROM DUAL; --入参的人员ID是否大于0,且如果账户变动类型为退款的,则不再调用 IF V_SIC83.AAC001 > 0 AND V_SIC83.CAE230 <> C_CAE230_SRTK THEN --调用养老帐户金额同步方法(ylgrzh_zhyetb)同步帐户金额 YLGRZH_ZHYETB(V_SIC83.AAC001, V_SIC83.AAE140, V_SIC83.AAE341, V_SIC83.AAC123, V_SIC83.AAC125, V_SIC83.AAC124, V_SIC83.AAC126, 0, 0, V_SIC83.CAE230, PO_FHZ, PO_MSG); --最后两个金额用0代入,待遇扣减方面的接口调用该过程会传入非0 IF PO_FHZ != ‘1‘ THEN RETURN; END IF; /* --begin Jinqingyu 20120111 注释 --查询帐户变更明细本人本险种最后变动记录的累计金额,并累加本次变动金额赋值给v_zhbgmx的累计部分 BEGIN SELECT CAC074, CAC075, CAC076, CAC077 INTO v_cac074,v_cac075,v_cac076,v_cac077 FROM SIC83 a WHERE aac001 = pi_sic83.aac001 AND aae140 = pi_sic83.aae140 AND cae176 = (SELECT MAX(cae176) FROM SIC83 WHERE aac001=pi_sic83.aac001 AND aae140=a.aae140) ; EXCEPTION WHEN NO_DATA_FOUND THEN v_cac074 := 0; v_cac075 := 0; v_cac076 := 0; v_cac077 := 0; END; v_sic83.cac074 := v_cac074 + NVL(v_sic83.cac074,0); v_sic83.cac075 := v_cac075 + NVL(v_sic83.cac075,0); v_sic83.cac076 := v_cac076 + NVL(v_sic83.cac076,0); v_sic83.cac077 := v_cac077 + NVL(v_sic83.cac077,0); --end Jinqingyu 20120111 注释 */ --将v_zhbgmx插入到养老个人帐户变更明细表(SIC83) INSERT INTO SIC83 VALUES V_SIC83; ELSE -- a 20120106 add 如果人员ID小于0直接生成收支明细,比如那些二类数据 --将v_zhbgmx插入到养老个人帐户变更明细表(SIC83) INSERT INTO SIC83 VALUES V_SIC83; END IF; END YLZHBGMX_SC; --养老个人帐户_帐户余额同步 PROCEDURE YLGRZH_ZHYETB(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_AAE341 IN VARCHAR2, --筹资项目 PI_BNGRJN IN NUMBER, --本年个人缴纳 PI_BNDWHR IN NUMBER, --本年单位划入 PI_BNJNLX IN NUMBER, --本年缴纳利息 PI_BNHRLX IN NUMBER, --本年划入利息 PI_DWJSJE IN NUMBER, --单位减少金额(传入金额为负数) PI_GRJSJE IN NUMBER, --个人减少金额(传入金额为负数) PI_CAE230 IN VARCHAR2, --账户变更类型 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_zhyetb‘; V_PROCPARAS VARCHAR2(3000); V_CAE246 SIC81.CAE246%TYPE; V_ZHZT_ZX SIC81.CAE246%TYPE; --综合参数_账户状态_注销 V_CZXM_CANL SIC83.AAE341%TYPE; V_CZXM_ZCJF SIC83.AAE341%TYPE; V_CZXM_ZHONGYANG SIC83.AAE341%TYPE; V_CZXM_MZ SIC83.AAE341%TYPE; V_CZXM_SHENG SIC83.AAE341%TYPE; V_CZXM_SHI SIC83.AAE341%TYPE; V_CZXM_ZCZ SIC83.AAE341%TYPE; V_CZXM_XIAN SIC83.AAE341%TYPE; V_CZXM_ZICHOU SIC83.AAE341%TYPE; V_YS NUMBER; --离年度的月数(用于计算月积数额) V_YJS_GXBZ VARCHAR2(3) := ‘0‘; --判断月积数更新的标志 V_YJS_BN TYPE_ZHJE; V_SIGN NUMBER := 1; --0和1(更新明细部分的标志) V_SIC81 SIC81%ROWTYPE; V_COUNT NUMBER; BEGIN V_PROCPARAS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_aae341=‘ || PI_AAE341 || ‘,pi_bngrjn=‘ || PI_BNGRJN || ‘,pi_bndwhr=‘ || PI_BNDWHR || ‘,pi_bnjnlx=‘ || PI_BNJNLX || ‘,pi_bnhrlx=‘ || PI_BNHRLX || ‘,pi_dwjsje=‘ || PI_DWJSJE || ‘,pi_grjsje=‘ || PI_GRJSJE || ‘,pi_cae230=‘ || PI_CAE230; PO_FHZ := ‘1‘; V_ZHZT_ZX := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZX‘); --获取账户状态_注销 V_CZXM_CANL := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘CANL‘); --残联 V_CZXM_ZCJF := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCJF‘); --正常缴费 V_CZXM_ZHONGYANG := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZHONGYANG‘); --中央财政 V_CZXM_MZ := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘MZ‘); --民政 V_CZXM_SHENG := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘SHENG‘); --省财政 V_CZXM_SHI := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘SHI‘); --市财政 V_CZXM_ZCZ := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCZ‘); --镇财政 V_CZXM_XIAN := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘XIAN‘); --县财政 V_CZXM_ZICHOU := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZICHOU‘); --自筹 --计算得到离年度的月数(用于计算月积数额) V_YS := 12 - TO_NUMBER(TO_CHAR(SYSDATE, ‘mm‘)) + 1; IF PI_CAE230 IS NULL THEN --帐户变动类型必须传入,否则抛出异常 PO_FHZ := V_PROCNAME || ‘_200‘; PO_MSG := ‘传入帐户变动类型为空.请重新核对.‘; RETURN; ELSE V_YJS_GXBZ := ‘0‘; --年度结息、年中结息时,更新月积数,存在结转等情况。由计息结息方法自行处理. --YANGYIXIN 20120913 ADD 计息类型为市外转入计息时不同步月积数 IF PI_CAE230 NOT IN (PKG_BXGX_CON.CAE230_NDJX, PKG_BXGX_CON.CAE230_NZJX, C_CAE320_SWZRJX) THEN V_YJS_GXBZ := ‘1‘; END IF; END IF; BEGIN SELECT CAE246 INTO V_CAE246 FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := V_PROCNAME || ‘_300‘; PO_MSG := ‘个人顺序号为:‘ || PI_AAC001 || ‘的养老个人账户不存在,不能同步养老个人帐户,请核实‘ || V_PROCPARAS; RETURN; WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_320‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ylgrzh_zhyetb"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; RETURN; END; IF V_CAE246 = V_ZHZT_ZX AND PI_CAE230 NOT IN (PKG_BXGX_CON.CAE230_DYZF) THEN PO_FHZ := V_PROCNAME || ‘_330‘; PO_MSG := ‘个人顺序号为:‘ || PI_AAC001 || ‘,险种类型为:‘ || PI_AAE140 || ‘,其养老账户状态为注销,不能同步养老个人帐户,请核实‘ || V_PROCPARAS; RETURN; END IF; --计算本年度的月积数额 IF V_YJS_GXBZ = ‘1‘ THEN V_YJS_BN.DWHR := (NVL(PI_BNDWHR, 0) + NVL(PI_BNHRLX, 0) - NVL(PI_DWJSJE, 0)) * V_YS; V_YJS_BN.GRJN := (NVL(PI_BNGRJN, 0) + NVL(PI_BNJNLX, 0) - NVL(PI_GRJSJE, 0)) * V_YS; ELSE V_YJS_BN.DWHR := 0; V_YJS_BN.GRJN := 0; END IF; ---20120523 Jinqingyu begin /* 所有的变动类型均需要同步余额。而明细的同步则情况比较多,规则细化如下: 1.如果是待遇支付类型的变动,则不扣明细部分 2.如果是关系的收支类型的变动(非计息),则同步明细 3.如果是关系的计息相关的收支变动,则 A.如果参保人已有待遇发放记录,则不同步明细 B.否则,同步明细 */ V_SIGN := 1; IF PI_CAE230 IN (PKG_BXGX_CON.CAE230_DYZF) THEN V_SIGN := 0; END IF; --20120215 Jinqingyu修改 退休人员(已有过待遇发放记录的) IF V_SIGN = 1 AND PI_CAE230 IN (PKG_BXGX_CON.CAE230_NDJX, PKG_BXGX_CON.CAE230_NZJX) THEN SELECT COUNT(1) INTO V_COUNT FROM SIC83 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND CAE230 = PKG_BXGX_CON.CAE230_DYZF; IF V_COUNT > 0 THEN V_SIGN := 0; END IF; END IF; ---20120523 Jinqingyu end --20120103 Jinqingyu修改 东莞不细化划入的筹资项目 --如果是年度结息,则更新的利息字段为历年利息字段 IF PI_CAE230 = PKG_BXGX_CON.CAE230_NDJX THEN UPDATE SIC81 SET AAE253 = NVL(AAE253, 0) + NVL(PI_BNDWHR, 0) * V_SIGN, --历年单位划入 AAE254 = NVL(AAE254, 0) + NVL(PI_BNGRJN, 0) * V_SIGN, --历年个人缴纳 AAE256 = NVL(AAE256, 0) + NVL(PI_BNHRLX, 0) * V_SIGN, --历年划入利息 AAE257 = NVL(AAE257, 0) + NVL(PI_BNJNLX, 0) * V_SIGN, --历年缴纳利息 CAC046 = NVL(CAC046, 0) + NVL(PI_BNDWHR, 0) + NVL(PI_BNHRLX, 0) + NVL(PI_DWJSJE, 0), --单位划入余额 CAC047 = NVL(CAC047, 0) + NVL(PI_BNGRJN, 0) + NVL(PI_BNJNLX, 0) + NVL(PI_GRJSJE, 0) --个人缴纳余额 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; ELSE UPDATE SIC81 SET AAE262 = NVL(AAE262, 0) + NVL(PI_BNDWHR, 0) * V_SIGN, --本年单位划入 AAE264 = NVL(AAE264, 0) + NVL(PI_BNGRJN, 0) * V_SIGN, --本年个人缴纳 AAE263 = NVL(AAE263, 0) + NVL(PI_BNHRLX, 0) * V_SIGN, --本年划入利息 AAE265 = NVL(AAE265, 0) + NVL(PI_BNJNLX, 0) * V_SIGN, --本年缴纳利息 CAC046 = NVL(CAC046, 0) + NVL(PI_BNDWHR, 0) + NVL(PI_BNHRLX, 0) + NVL(PI_DWJSJE, 0), --单位划入余额 CAC047 = NVL(CAC047, 0) + NVL(PI_BNGRJN, 0) + NVL(PI_BNJNLX, 0) + NVL(PI_GRJSJE, 0), --个人缴纳余额 CIE579 = NVL(CIE579, 0) + V_YJS_BN.DWHR, --本年积数额_单位划入 CIE580 = NVL(CIE580, 0) + V_YJS_BN.GRJN --本年积数额_个人缴纳 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; END IF; --begin 判断一下余额(扣减后再反向校验) 20120111 Jinqignyu 放开校验 /* pkg_zhgl.ylgrzh_cx(pi_aac001,pi_aae140,v_sic81,po_fhz,po_msg); if po_fhz<>‘1‘ THEN RETURN; end if; --判断一下余额(扣减后再反向校验) IF NVL(v_sic81.CAC046,0)<0 or NVL(v_sic81.CAC047,0)<0 THEN po_fhz := v_procname||‘_500‘; po_msg := ‘账户余额同步后,余额部分为负数。请核实‘||v_procparas; RETURN; END IF; */ --end 判断一下余额(扣减后再反向校验) /* --筹资项目为正常缴费 IF pi_aae341= V_CZXM_ZCJF THEN --更新正常缴费部分金额和余额 UPDATE sic81 SET AAE264 = NVL(AAE264,0) + NVL(pi_bngrjn,0) , AAE262 = NVL(AAE262,0) + NVL(pi_bndwhr,0) , AAE265 = NVL(AAE265,0) + NVL(pi_bnjnlx,0) , AAE263 = NVL(AAE263,0) + NVL(pi_bnhrlx,0) , CAC047 = NVL(CAC047,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0) + NVL(pi_grjsje,0), CAC046 = NVL(CAC046,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_dwjsje,0) WHERE aac001 = pi_aac001+ NVL(pi_dwjsje,0) AND aae140 = pi_aae140 ; --计算月积数额 if v_yjs_gxbz=‘1‘ then v_yjs_bn.dwhr:= (NVL(pi_bngrjn,0)+NVL(pi_bnhrlx,0)+ NVL(pi_dwjsje,0))*v_ys; v_yjs_bn.grjn:= (NVL(pi_bngrjn,0)+NVL(pi_bnjnlx,0)+ NVL(pi_grjsje,0))*v_ys; end if; --筹资项目为省财政 ELSIF pi_aae341= V_CZXM_SHENG THEN--更新省财政部分金额和余额 UPDATE sic81 SET CAC054 = NVL(CAC054,0) + NVL(pi_bndwhr,0) + NVL(pi_bngrjn,0), CAC062 = NVL(CAC062,0) + NVL(pi_bnhrlx,0) + NVL(pi_bnjnlx,0), CAC070 = NVL(CAC070,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0), --同步更新划入余额 CAC046 = NVL(CAC046,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_dwjsje,0), CAC047 = NVL(CAC047,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0) + NVL(pi_grjsje,0)--如果是财政补贴,这部分都应该为0 WHERE aac001 = pi_aac001 AND aae140 = pi_aae140 ; --计算月积数额 if v_yjs_gxbz=‘1‘ then v_yjs_bn.hr_sheng:= (NVL(pi_bngrjn,0)+NVL(pi_bnhrlx,0))*v_ys; end if; --筹资项目为市财政 ELSIF pi_aae341= V_CZXM_SHI THEN --更新市财政部分金额和余额 UPDATE sic81 SET CAC055 = NVL(CAC055,0) + NVL(pi_bndwhr,0) + NVL(pi_bngrjn,0), CAC063 = NVL(CAC063,0) + NVL(pi_bnhrlx,0) + NVL(pi_bnjnlx,0), CAC071 = NVL(CAC071,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0), --同步更新划入余额 CAC046 = NVL(CAC046,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_dwjsje,0), CAC047 = NVL(CAC047,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0) + NVL(pi_grjsje,0)--如果是财政补贴,这部分都应该为0 WHERE aac001 = pi_aac001 AND aae140 = pi_aae140 ; --计算月积数额 if v_yjs_gxbz=‘1‘ then v_yjs_bn.hr_shi:= (NVL(pi_bngrjn,0)+NVL(pi_bnhrlx,0))*v_ys; end if; --筹资项目为区县财政 ELSIF pi_aae341 IN (V_CZXM_ZCZ,V_CZXM_XIAN) THEN--更新区县财政部分金额和余额 UPDATE sic81 SET CAC056 = NVL(CAC056,0) + NVL(pi_bndwhr,0) + NVL(pi_bngrjn,0), CAC064 = NVL(CAC064,0) + NVL(pi_bnhrlx,0) + NVL(pi_bnjnlx,0), CAC072 = NVL(CAC072,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0), --同步更新划入余额 CAC046 = NVL(CAC046,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_dwjsje,0), CAC047 = NVL(CAC047,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0) + NVL(pi_grjsje,0)--如果是财政补贴,这部分都应该为0 WHERE aac001 = pi_aac001 AND aae140 = pi_aae140 ; --计算月积数额 if v_yjs_gxbz=‘1‘ then v_yjs_bn.hr_qu:= (NVL(pi_bngrjn,0)+NVL(pi_bnhrlx,0))*v_ys; end if; --筹资项目为其它财政 ELSE --更新其他财政部分金额和余额 UPDATE sic81 SET CAC057 = NVL(CAC057,0) + NVL(pi_bndwhr,0) + NVL(pi_bngrjn,0), CAC065 = NVL(CAC065,0) + NVL(pi_bnhrlx,0) + NVL(pi_bnjnlx,0), CAC073 = NVL(CAC073,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0), --同步更新划入余额 CAC046 = NVL(CAC046,0) + NVL(pi_bndwhr,0) + NVL(pi_bnhrlx,0) + NVL(pi_dwjsje,0), CAC047 = NVL(CAC047,0) + NVL(pi_bngrjn,0) + NVL(pi_bnjnlx,0) + NVL(pi_grjsje,0)--如果是财政补贴,这部分都应该为0 WHERE aac001 = pi_aac001 AND aae140 = pi_aae140 ; --计算月积数额 if v_yjs_gxbz=‘1‘ then v_yjs_bn.hr_qtcz:= (NVL(pi_bngrjn,0)+NVL(pi_bnhrlx,0))*v_ys; end if; END IF; */ EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.ylgrzh_zhyetb_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ylgrzh_zhyetb"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘pi_aae341:‘ || PI_AAE341 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END YLGRZH_ZHYETB; --账户金额同步_个人退款 PROCEDURE YLGRZH_ZHYETB_TK(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_AAE341 IN VARCHAR2, --筹资项目 PI_BNGRJN IN NUMBER, --本年个人缴纳 PI_BNDWHR IN NUMBER, --本年单位划入 PI_BNJNLX IN NUMBER, --本年缴纳利息 PI_BNHRLX IN NUMBER, --本年划入利息 PI_LNGRJN IN NUMBER, --历年个人缴纳 PI_LNDWHR IN NUMBER, --历年单位划入 PI_LNJNLX IN NUMBER, --历年缴纳利息 PI_LNHRLX IN NUMBER, --历年划入利息 PI_CAE230 IN VARCHAR2, --账户变更类型 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_zhyetb‘; V_PROCPARAS VARCHAR2(3000); V_CAE246 SIC81.CAE246%TYPE; V_ZHZT_ZX SIC81.CAE246%TYPE; --综合参数_账户状态_注销 V_CZXM_CANL SIC83.AAE341%TYPE; V_CZXM_ZCJF SIC83.AAE341%TYPE; V_CZXM_ZHONGYANG SIC83.AAE341%TYPE; V_CZXM_MZ SIC83.AAE341%TYPE; V_CZXM_SHENG SIC83.AAE341%TYPE; V_CZXM_SHI SIC83.AAE341%TYPE; V_CZXM_ZCZ SIC83.AAE341%TYPE; V_CZXM_XIAN SIC83.AAE341%TYPE; V_CZXM_ZICHOU SIC83.AAE341%TYPE; V_YS NUMBER; --离年度的月数(用于计算月积数额) V_YJS_BN TYPE_ZHJE; V_SIC81 SIC81%ROWTYPE; V_COUNT NUMBER; V_TKBJ NUMBER; --退款本金 BEGIN V_PROCPARAS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_aae341=‘ || PI_AAE341 || ‘,pi_bngrjn=‘ || PI_BNGRJN || ‘,pi_bndwhr=‘ || PI_BNDWHR || ‘,pi_bnjnlx=‘ || PI_BNJNLX || ‘,pi_bnhrlx=‘ || PI_BNHRLX || ‘,pi_lngrjn=‘ || PI_LNGRJN || ‘,pi_lndwhr=‘ || PI_LNDWHR || ‘,pi_lnjnlx=‘ || PI_LNJNLX || ‘,pi_lnhrlx‘ || PI_LNHRLX || ‘,pi_CAE230‘ || PI_CAE230; PO_FHZ := ‘1‘; V_ZHZT_ZX := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZX‘); --获取账户状态_注销 V_CZXM_CANL := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘CANL‘); --残联 V_CZXM_ZCJF := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCJF‘); --正常缴费 V_CZXM_ZHONGYANG := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZHONGYANG‘); --中央财政 V_CZXM_MZ := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘MZ‘); --民政 V_CZXM_SHENG := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘SHENG‘); --省财政 V_CZXM_SHI := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘SHI‘); --市财政 V_CZXM_ZCZ := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCZ‘); --镇财政 V_CZXM_XIAN := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘XIAN‘); --县财政 V_CZXM_ZICHOU := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZICHOU‘); --自筹 --计算得到离年度的月数(用于计算月积数额) V_YS := 12 - TO_NUMBER(TO_CHAR(SYSDATE, ‘mm‘)) + 1; IF PI_CAE230 IS NULL THEN --帐户变动类型必须传入,否则抛出异常 PO_FHZ := V_PROCNAME || ‘_200‘; PO_MSG := ‘传入帐户变动类型为空.请重新核对.‘; RETURN; END IF; IF PI_CAE230 <> PKG_BXGX_CON.CAE230_SRTK THEN --帐户变动类型必须为收入退款,否则抛出异常 PO_FHZ := V_PROCNAME || ‘_205‘; PO_MSG := ‘传入帐户变动类型不为收入退款.请重新核对.‘ || V_PROCPARAS; RETURN; END IF; BEGIN SELECT CAE246 INTO V_CAE246 FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := V_PROCNAME || ‘_300‘; PO_MSG := ‘个人顺序号为:‘ || PI_AAC001 || ‘的养老个人账户不存在,不能同步养老个人帐户,请核实‘ || V_PROCPARAS; RETURN; WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_320‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ylgrzh_zhyetb_grtk"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; RETURN; END; IF V_CAE246 = V_ZHZT_ZX THEN PO_FHZ := V_PROCNAME || ‘_330‘; PO_MSG := ‘个人顺序号为:‘ || PI_AAC001 || ‘,险种类型为:‘ || PI_AAE140 || ‘,其养老账户状态为注销,不能同步养老个人帐户,请核实‘ || V_PROCPARAS; RETURN; END IF; --退款本金 V_TKBJ := NVL(PI_BNDWHR, 0) + NVL(PI_BNGRJN, 0) + NVL(PI_LNDWHR, 0) + NVL(PI_LNGRJN, 0); /* 所有的变动类型均需要同步余额。而明细的同步则情况比较多,规则细化如下: 1.如果是待遇支付类型的变动,则不扣明细部分 2.如果是关系的收支类型的变动(非计息),则同步明细 3.如果是关系的计息相关的收支变动,则 A.如果参保人已有待遇发放记录,则不同步明细 B.否则,同步明细 帐户变动类型为收入退款时,对记录进行如下更新: 1. 更新对应的本历年金额部分(AAE253,AAE254,AAE256,AAE257)和余额部分(CAC046,CAC047) 2. 更新本年月积数额对应字段:本年月积数额=本年月积数额 - (退款本金+历年部分利息)*(12- M) 其中:M为当年自然时候到月底的月数,如当前为2012-5-14,则M=7 */ UPDATE SIC81 SET AAE262 = NVL(AAE262, 0) + NVL(PI_BNDWHR, 0), --本年单位划入 AAE264 = NVL(AAE264, 0) + NVL(PI_BNGRJN, 0), --本年个人缴纳 AAE263 = NVL(AAE263, 0) + NVL(PI_BNHRLX, 0), --本年划入利息 AAE265 = NVL(AAE265, 0) + NVL(PI_BNJNLX, 0), --本年缴纳利息 AAE253 = NVL(AAE253, 0) + NVL(PI_LNDWHR, 0), --历年单位划入 AAE254 = NVL(AAE254, 0) + NVL(PI_LNGRJN, 0), --历年个人缴纳 AAE256 = NVL(AAE256, 0) + NVL(PI_LNHRLX, 0), --历年划入利息 AAE257 = NVL(AAE257, 0) + NVL(PI_LNJNLX, 0), --历年缴纳利息 CAC046 = NVL(CAC046, 0) + NVL(PI_BNDWHR, 0) + NVL(PI_BNHRLX, 0) + NVL(PI_LNDWHR, 0) + NVL(PI_LNHRLX, 0), --单位划入余额 CAC047 = NVL(CAC047, 0) + NVL(PI_BNGRJN, 0) + NVL(PI_BNJNLX, 0) + NVL(PI_LNGRJN, 0) + NVL(PI_LNJNLX, 0), --个人缴纳余额 CIE579 = NVL(CIE579, 0) + (V_TKBJ + PI_LNHRLX) * (12 - V_YS), --本年积数额_单位划入 CIE580 = NVL(CIE580, 0) + (V_TKBJ + PI_LNJNLX) * (12 - V_YS) --本年积数额_个人缴纳 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.ylgrzh_zhyetb_tk_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.ylgrzh_zhyetb_tk"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘pi_aae341:‘ || PI_AAE341 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END YLGRZH_ZHYETB_TK; --养老账户明细_个人应缴转化 PROCEDURE YLZHBGMX_GRYJ(PI_AC43 IN AC43%ROWTYPE, --行记录 PI_CAE231 IN VARCHAR2, --业务关键字段 PI_CAE232 IN VARCHAR2, --业务关键字段值 PI_CAE230 IN VARCHAR2, --账户变动类型 PI_AAE013 IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_SIC83 SIC83%ROWTYPE; --养老账户变更明细记录 V_AC43 AC43 %ROWTYPE; --应缴记录 V_SZBZ_SR SIC83.CAE178%TYPE; --综合参数_收支标志_收入 V_LXJSBZ_JS SIC83.CAA034%TYPE; --综合参数_利息计算标志_计算 V_SJLX_YLSJ SIC83.CAE682%TYPE; --综合参数_数据类型_一类数据 V_YJLX_TS AC43.AAA115%TYPE; --综合参数_应缴类型_退收 BEGIN PO_FHZ := ‘1‘; V_SZBZ_SR := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘SR‘); --获取收支标志_收入的综合参数 V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_SJLX_YLSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘YLSJ‘); --获取综合参数数据类型_一类数据 V_YJLX_TS := PKG_FUN.F_GET_DICT(‘AAA115‘, ‘TS‘); --综合参数_应缴类型_退收 V_SIC83.BAE001 := PI_AC43.BAE001; --系统机构代码 V_SIC83.AAB001 := PI_AC43.AAB001; --单位顺序号 V_SIC83.AAC001 := PI_AC43.AAC001; --个人顺序号 V_SIC83.AAE140 := PI_AC43.AAE140; --险种类型 --v_sic83.jflb := pi_ac43.jflb; --缴费类别 --v_sic83.cae121 := pi_ac43.cae121;--所属年月 V_SIC83.AAE341 := PI_AC43.AAE341; --筹资项目 --v_sic83.tzny := pi_ac43.shny; --台帐年月 V_SIC83.CAE177 := PI_AC43.AAE108; --收支方式 --v_sic83.jfjs := pi_ac43.jfjs; --缴费基数 --v_sic83.zhjznjrq := pi_ac43.zhjznjrq;--最后计滞纳金日期 --v_sic83.cae125 := pi_ac43.cae125; --台帐变更顺序号 --v_sic83.hbywlsh := pi_ac43.hbywlsh;--合并业务流水号 IF PI_AC43.AAE013 IS NOT NULL THEN V_SIC83.AAE013 := PI_AC43.AAE013 || ‘,‘ || PI_AAE013; --备注 ELSE V_SIC83.AAE013 := PI_AAE013; END IF; V_SIC83.CAE230 := PI_CAE230; --账户变动类型 V_SIC83.CAE178 := V_SZBZ_SR; --收支标志:收入 --v_sic83.cwjzbz := pkg_con.cwjzbz_wjz;--财务记账标志 V_SIC83.CAA034 := V_LXJSBZ_JS; --计息标志(默认计息) V_SIC83.CAE233 := NVL(PI_AC43.CAE128, TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘))); --账户写入日期 ,用配置时间代入 --财务确认时间:暂时用缴款日期 BEGIN SELECT AAD017 INTO V_SIC83.CAE683 FROM AD24 WHERE CAE320 = PI_AC43.CAE320; EXCEPTION WHEN NO_DATA_FOUND THEN --po_fhz := ‘PKG_ZHGL.Ylzhbgmx_gryj_10‘; -- 请查看详细出错信息 --po_msg := ‘调用"PKG_ZHGL.Ylzhbgmx_gryj"时系统错误,系统错误信息:‘||sqlerrm||‘!‘; --RETURN; --TODO:目前办理退款时传进来的记录是没有缴费顺序号的,暂时先默认为当前日期,这个等以后跟杨工确认 --add by liuzhq 2011-12-9 V_SIC83.CAE683 := PKG_FUN.F_GET_SYSDATE(14); END; V_SIC83.CAE682 := V_SJLX_YLSJ; --数据类型,一类数据 V_SIC83.CAE684 := 0; V_SIC83.AAA031 := 0; --利率 --如果传入参数中的业务关键字段不为空,则取传入参数,否则取缴费顺序号CAE320 IF NVL(PI_CAE231, ‘X‘) <> ‘X‘ THEN V_SIC83.CAE231 := PI_CAE231; --业务关键字段 V_SIC83.CAE232 := PI_CAE232; --业务关键字段值 ELSE V_SIC83.CAE231 := ‘CAE320‘; --业务关键字段 V_SIC83.CAE232 := PI_AC43.CAE320; --业务关键字段值 END IF; --应缴类型为退款? IF PI_AC43.AAA115 = V_YJLX_TS THEN --所有金额为负数赋值给v_zhbgmx对应的金额字段 V_SIC83.AAC123 := 0 - NVL(PI_AC43.AAC123, 0); --个人缴费金额 V_SIC83.AAC125 := 0 - NVL(PI_AC43.AAC125, 0); --划入账户金额 V_SIC83.AAC127 := 0 - NVL(PI_AC43.AAC127, 0); --划入统筹金额 V_SIC83.AAC124 := 0 - NVL(PI_AC43.AAC124, 0); --个人缴费利息 V_SIC83.AAC126 := 0 - NVL(PI_AC43.AAC126, 0); --划入账户利息 V_SIC83.AAC128 := 0 - NVL(PI_AC43.AAC128, 0); --划入统筹利息 ELSE --所有金额赋值给v_zhbgmx对应的金额字段 V_SIC83.AAC123 := PI_AC43.AAC123; --个人缴费金额 V_SIC83.AAC125 := PI_AC43.AAC125; --划入账户金额 V_SIC83.AAC127 := PI_AC43.AAC127; --划入统筹金额 V_SIC83.AAC124 := PI_AC43.AAC124; --个人缴费利息 V_SIC83.AAC126 := PI_AC43.AAC126; --划入账户利息 V_SIC83.AAC128 := PI_AC43.AAC128; --划入统筹利息 END IF; --szn 20111213 modify V_SIC83.CAC074 := V_SIC83.AAC123; V_SIC83.CAC075 := V_SIC83.AAC125; V_SIC83.CAC076 := V_SIC83.AAC124; V_SIC83.CAC077 := V_SIC83.AAC126; --调用养老账户变更明细_生成方法生成养老帐户变更明细 YLZHBGMX_SC(V_SIC83, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_gryj_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_gryj"时系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YLZHBGMX_GRYJ; --养老账户收支明细生成_个人退款 PROCEDURE YLZHBGMX_GRTK(PI_AC43 IN AC43%ROWTYPE, --行记录 PI_CAE231 IN VARCHAR2, --业务关键字段 PI_CAE232 IN VARCHAR2, --业务关键字段值 PI_CAE230 IN VARCHAR2, --账户变动类型 PI_AAE013 IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_SIC83 SIC83%ROWTYPE; --养老账户变更明细记录 V_AC43 AC43 %ROWTYPE; --应缴记录 V_CAE320 AC43.CAE320%TYPE; --缴费顺序号 V_DZRQ NUMBER; --到账日期 V_SZBZ_SR SIC83.CAE178%TYPE; --综合参数_收支标志_收入 V_LXJSBZ_JS SIC83.CAA034%TYPE; --综合参数_利息计算标志_计算 V_SJLX_YLSJ SIC83.CAE682%TYPE; --综合参数_数据类型_一类数据 V_YJLX_TS AC43.AAA115%TYPE; --综合参数_应缴类型_退收 V_GRJFLX NUMBER; --个人缴费利息 V_HRZHLX NUMBER; --划入帐户利息 V_HRTCLX NUMBER; --划入统筹利息 V_BNGRJN NUMBER := 0; --本年个人缴纳 V_BNDWHR NUMBER := 0; --本年单位划入 V_BNJNLX NUMBER := 0; --本年缴纳利息 V_BNHRLX NUMBER := 0; --本年划入利息 V_LNGRJN NUMBER := 0; --历年个人缴纳 V_LNDWHR NUMBER := 0; --历年单位划入 V_LNJNLX NUMBER := 0; --历年缴纳利息 V_LNHRLX NUMBER := 0; --历年划入利息 V_ZZRQ DATE; --终止日期 V_SAD01 SAD01%ROWTYPE; --台帐变更记录 V_BAE007 VARCHAR2(64); --办理退款业务对应的业务流水号 BEGIN PO_FHZ := ‘1‘; V_SZBZ_SR := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘SR‘); --获取收支标志_收入的综合参数 V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_SJLX_YLSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘YLSJ‘); --获取综合参数数据类型_一类数据 V_YJLX_TS := PKG_FUN.F_GET_DICT(‘AAA115‘, ‘TS‘); --综合参数_应缴类型_退收 --如果应缴类型不为退款,则直接返回错误。并提示“传入的类型不为个人退款,不能使用本方法” IF PI_AC43.AAA115 <> V_YJLX_TS THEN PO_FHZ := ‘PKG_ZHGL.ylzhbgmx_grtk_01‘; PO_MSG := ‘传入的类型不为个人退款,不能使用本方法‘ || ‘,传入参数为CAE125=‘ || PI_AC43.CAE125 || ‘,应缴类型为‘ || PI_AC43.AAA115; RETURN; END IF; --根据台帐变更顺序号取变更记录 PKG_TZBG.TZBGJL_CX(PI_CAE232, V_SAD01, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_BAE007 := V_SAD01.BAE007; --办理退款业务对应的业务流水号 add by liuzhq 2012-08-21 --通过入参人员征缴明细去查找对应的原实缴记录,只能在退款备份表中查对应的缴费顺序号 BEGIN SELECT CAE320 INTO V_CAE320 FROM SAE18 WHERE NVL(CAE320, 0) <> 0 AND AAC001 = PI_AC43.AAC001 AND AAB001 = PI_AC43.AAB001 AND CAE121 = PI_AC43.CAE121 AND CAE122 = PI_AC43.CAE121 AND AAE341 = PI_AC43.AAE341 AND AAE140 = PI_AC43.AAE140 AND CAE837 = V_BAE007 --只查询合并业务流水号为当前退款业务对应的业务流水号(因为人员合并业务也有可能产生SAE18表中的数据) add by liuzhq 2012-08-21 AND BCE094 = C_BCE094_YJ AND ROWNUM = 1; EXCEPTION WHEN NO_DATA_FOUND THEN --若不存在,则以退款的那条人员征缴明细中的aae002作为到账年月 BEGIN SELECT TO_NUMBER(AAE002 || ‘01‘) INTO V_DZRQ FROM SAE18 WHERE AAC001 = PI_AC43.AAC001 AND AAB001 = PI_AC43.AAB001 AND CAE121 = PI_AC43.CAE121 AND CAE122 = PI_AC43.CAE121 AND AAE341 = PI_AC43.AAE341 AND AAE140 = PI_AC43.AAE140 AND CAE837 = V_BAE007 --只查询合并业务流水号为当前退款业务对应的业务流水号(因为人员合并业务也有可能产生SAE18表中的数据) AND BCE094 = C_BCE094_YJ AND ROWNUM = 1; EXCEPTION WHEN NO_DATA_FOUND THEN BEGIN SELECT TO_NUMBER(AAE002 || ‘01‘) INTO V_DZRQ FROM SAE18 WHERE AAC001 = PI_AC43.AAC001 AND AAB001 = PI_AC43.AAB001 AND CAE121 = PI_AC43.CAE121 AND CAE122 = PI_AC43.CAE121 AND PI_AC43.CAE121 < 201201 --只有缴费年月为老系统数据时,才可能存在拆分数据 AND AAE341 = C_AAE341_ZCJF AND PI_AC43.AAE341 IN (C_AAE341_FPCZFD, C_AAE341_FPCSFD) AND AAE140 = PI_AC43.AAE140 AND CAE837 = V_BAE007 --只查询合并业务流水号为当前退款业务对应的业务流水号(因为人员合并业务也有可能产生SAE18表中的数据) AND BCE094 = C_BCE094_YJ AND ROWNUM = 1; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grtk_02‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grtk"时出现错误,找不到对应的退款备份记录:‘ || SQLERRM || ‘!‘ || ‘aac001=‘ || PI_AC43.AAC001 || ‘,aab001=‘ || PI_AC43.AAB001 || ‘,cae121=‘ || PI_AC43.CAE121 || ‘,aae341=‘ || PI_AC43.AAE341 || ‘,aae140=‘ || PI_AC43.AAE140; RETURN; END; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grtk_03‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grtk"时出现错误,找不到对应的退款备份记录:‘ || SQLERRM || ‘!‘ || ‘aac001=‘ || PI_AC43.AAC001 || ‘,aab001=‘ || PI_AC43.AAB001 || ‘,cae121=‘ || PI_AC43.CAE121 || ‘,aae341=‘ || PI_AC43.AAE341 || ‘,aae140=‘ || PI_AC43.AAE140; RETURN; END; END; --若存在缴费顺序号且到账日期不为空,则以原实缴记录中的缴费顺序号去AD24表中获取到账年月 IF V_DZRQ IS NULL THEN BEGIN SELECT AAD017 INTO V_DZRQ FROM AD24 WHERE CAE320 = V_CAE320; EXCEPTION WHEN NO_DATA_FOUND THEN --若不存在,则以退款的那条人员征缴明细中的aae002作为到账年月 BEGIN SELECT TO_NUMBER(AAE002 || ‘01‘) INTO V_DZRQ FROM SAE18 WHERE AAC001 = PI_AC43.AAC001 AND AAB001 = PI_AC43.AAB001 AND CAE121 = PI_AC43.CAE121 AND CAE122 = PI_AC43.CAE121 AND AAE341 = PI_AC43.AAE341 AND AAE140 = PI_AC43.AAE140 AND CAE837 = V_BAE007 --只查询合并业务流水号为当前退款业务对应的业务流水号(因为人员合并业务也有可能产生SAE18表中的数据) AND BCE094 = C_BCE094_YJ AND ROWNUM = 1; EXCEPTION WHEN NO_DATA_FOUND THEN BEGIN SELECT TO_NUMBER(AAE002 || ‘01‘) INTO V_DZRQ FROM SAE18 WHERE AAC001 = PI_AC43.AAC001 AND AAB001 = PI_AC43.AAB001 AND CAE121 = PI_AC43.CAE121 AND CAE122 = PI_AC43.CAE121 AND PI_AC43.CAE121 < 201201 --只有缴费年月为老系统数据时,才可能存在拆分数据 AND AAE341 = C_AAE341_ZCJF AND PI_AC43.AAE341 IN (C_AAE341_FPCZFD, C_AAE341_FPCSFD) AND AAE140 = PI_AC43.AAE140 AND CAE837 = V_BAE007 --只查询合并业务流水号为当前退款业务对应的业务流水号(因为人员合并业务也有可能产生SAE18表中的数据) AND BCE094 = C_BCE094_YJ AND ROWNUM = 1; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grtk_02‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grtk"时出现错误,找不到对应的退款备份记录:‘ || SQLERRM || ‘!‘ || ‘aac001=‘ || PI_AC43.AAC001 || ‘,aab001=‘ || PI_AC43.AAB001 || ‘,cae121=‘ || PI_AC43.CAE121 || ‘,aae341=‘ || PI_AC43.AAE341 || ‘,aae140=‘ || PI_AC43.AAE140; RETURN; END; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grtk_04‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grtk"时出现错误,找不到对应的退款备份记录:‘ || SQLERRM || ‘!‘ || ‘aac001=‘ || PI_AC43.AAC001 || ‘,aab001=‘ || PI_AC43.AAB001 || ‘,cae121=‘ || PI_AC43.CAE121 || ‘,aae341=‘ || PI_AC43.AAE341 || ‘,aae140=‘ || PI_AC43.AAE140; RETURN; END; END; END IF; V_SIC83.BAE001 := PI_AC43.BAE001; --系统机构代码 V_SIC83.AAB001 := PI_AC43.AAB001; --单位顺序号 V_SIC83.AAC001 := PI_AC43.AAC001; --个人顺序号 V_SIC83.AAE140 := PI_AC43.AAE140; --险种类型 V_SIC83.AAE341 := PI_AC43.AAE341; --筹资项目 V_SIC83.CAE177 := PI_AC43.AAE108; --收支方式 IF PI_AC43.AAE013 IS NOT NULL THEN V_SIC83.AAE013 := PI_AC43.AAE013 || ‘,‘ || PI_AAE013; --备注 ELSE V_SIC83.AAE013 := PI_AAE013; --备注 END IF; V_SIC83.CAE230 := PI_CAE230; --账户变动类型 V_SIC83.CAE178 := V_SZBZ_SR; --收支标志:收入 V_SIC83.CAA034 := V_LXJSBZ_JS; --计息标志(默认计息) V_SIC83.CAE233 := NVL(PI_AC43.CAE128, TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘))); --账户写入日期 ,用配置时间代入 V_SIC83.CAE683 := V_DZRQ; V_SIC83.CAE682 := V_SJLX_YLSJ; --数据类型,一类数据 V_SIC83.CAE684 := 0; V_SIC83.AAA031 := 0; --利率 V_SIC83.CAE231 := PI_CAE231; --业务关键字段 V_SIC83.CAE232 := PI_CAE232; --业务关键字段值 --因为应缴类型为退款,故养老收支明细的记录都是负数 V_SIC83.AAC123 := 0 - NVL(PI_AC43.AAC123, 0); --个人缴费金额 V_SIC83.AAC125 := 0 - NVL(PI_AC43.AAC125, 0); --划入账户金额 V_SIC83.AAC127 := 0 - NVL(PI_AC43.AAC127, 0); --划入统筹金额 V_SIC83.AAC124 := 0 - NVL(PI_AC43.AAC124, 0); --个人缴费利息 V_SIC83.AAC126 := 0 - NVL(PI_AC43.AAC126, 0); --划入账户利息 V_SIC83.AAC128 := 0 - NVL(PI_AC43.AAC128, 0); --划入统筹利息 V_SIC83.CAC074 := V_SIC83.AAC123; --累计个人缴费 V_SIC83.CAC075 := V_SIC83.AAC125; --累计单位划入帐户 V_SIC83.CAC076 := V_SIC83.AAC124; --累计个人缴费利息 V_SIC83.CAC077 := V_SIC83.AAC126; --累计单位缴费利息 --调用养老账户变更明细_生成方法生成养老帐户变更明细 YLZHBGMX_SC(V_SIC83, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --判断到账日期是否为历年的,若是,则计算本金计息到上年末12月所得到的利息 IF SUBSTRB(V_DZRQ, 1, 4) < PKG_FUN.F_GET_SYSDATE(4) THEN V_ZZRQ := TO_DATE(PKG_FUN.F_GET_SYSDATE(4) - 1 || ‘12‘, ‘yyyymm‘); --终止日期 --计算利息 PKG_YSHD.GET_LX_BY_YJS(PI_AC43.BAE001, PI_AC43.AAC123, PI_AC43.AAC125, PI_AC43.AAC127, TO_DATE(PI_AC43.CAE121, ‘yyyymm‘), V_ZZRQ, V_GRJFLX, V_HRZHLX, V_HRTCLX, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --比较当前人员征缴明细中的利息是否大于计算出来的利息,若大于,则要区分历年利息则本年利息 IF NVL(V_GRJFLX, 0) < NVL(PI_AC43.AAC124, 0) THEN V_BNJNLX := NVL(V_GRJFLX, 0) - NVL(PI_AC43.AAC124, 0); --本年缴纳利息 V_BNHRLX := NVL(V_HRZHLX, 0) - NVL(PI_AC43.AAC126, 0); --本年划入利息 V_LNGRJN := 0 - PI_AC43.AAC123; --历年个人缴纳 V_LNDWHR := 0 - PI_AC43.AAC125; --历年单位划入 V_LNJNLX := 0 - NVL(V_GRJFLX, 0); --历年缴纳利息 V_LNHRLX := 0 - NVL(V_HRZHLX, 0); --历年划入利息 ELSE V_LNGRJN := 0 - PI_AC43.AAC123; --历年个人缴纳 V_LNDWHR := 0 - PI_AC43.AAC125; --历年单位划入 V_LNJNLX := 0 - NVL(PI_AC43.AAC124, 0); --历年缴纳利息 V_LNHRLX := 0 - NVL(PI_AC43.AAC126, 0); --历年划入利息 END IF; --计算得到本年部分利息,本金全部为历年本金 ELSE V_BNGRJN := 0 - NVL(PI_AC43.AAC123, 0); --本年缴纳金额 V_BNDWHR := 0 - NVL(PI_AC43.AAC125, 0); --本年划入金额 V_BNJNLX := 0 - NVL(PI_AC43.AAC124, 0); --本年缴纳利息 V_BNHRLX := 0 - NVL(PI_AC43.AAC126, 0); --本年划入利息 END IF; --调用账户金额同步_个人退款方法 YLGRZH_ZHYETB_TK(V_SIC83.AAC001, V_SIC83.AAE140, V_SIC83.AAE341, V_BNGRJN, V_BNDWHR, V_BNJNLX, V_BNHRLX, V_LNGRJN, V_LNDWHR, V_LNJNLX, V_LNHRLX, V_SIC83.CAE230, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grtk_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grtk"时系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YLZHBGMX_GRTK; --养老账户变更明细_其他应收 PROCEDURE YLZHBGMX_QTYS(PI_AAB001 IN NUMBER, --组织ID PI_AAC001 IN NUMBER, --人员ID PI_BAE001 IN VARCHAR2, --系统机构代码 PI_CAE231 IN VARCHAR2, --业务关键字段 PI_CAE232 IN NUMBER, --业务关键字段值 PI_AAE140 IN VARCHAR2, --险种类型 PI_AAE341 IN VARCHAR2, --筹资项目 PI_CAE233 IN NUMBER, --帐户写入时间 PI_AAC123 IN NUMBER, --个人缴费金额 PI_AAC125 IN NUMBER, --划入账户金额 PI_AAC127 IN NUMBER, --划入统筹金额 PI_CAE230 IN VARCHAR2, --账户变动类型 PI_CAE178 IN VARCHAR2, --收支类型 PI_AAE013 IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2, --返回消息 PI_CAE682 IN VARCHAR2 DEFAULT ‘1‘ -- 数据类型:默认一类数据 ) IS V_SIC83 SIC83%ROWTYPE; V_LXJSBZ_JS SIC83.CAA034%TYPE; --综合参数_利息计算标志_计算 V_LXJSBZ_BJS SIC83.CAA034%TYPE; --综合参数_利息计算标志_不计算 V_SJLX_YLSJ SIC83.CAE682%TYPE; --综合参数_数据类型_一类数据 V_SJLX_ELSJ SIC83.CAE682%TYPE; --综合参数_数据类型_二类数据 V_SZBZ_ZC SIC83.CAE178%TYPE; --收支标志_支出 V_SZFS_ZXJF SIC83.CAE177%TYPE; BEGIN PO_FHZ := ‘1‘; V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_LXJSBZ_BJS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘BJS‘); --获取利息计算标志_不计算的综合参数 V_SJLX_YLSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘YLSJ‘); --获取综合参数数据类型_一类数据 V_SJLX_ELSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘ELSJ‘); --获取综合参数数据类型_二类数据 V_SZBZ_ZC := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘ZC‘); V_SZFS_ZXJF := PKG_FUN.F_GET_DICT(‘CAE177‘, ‘ZXJF‘); V_SIC83.BAE001 := PI_BAE001; --系统机构代码 V_SIC83.AAB001 := PI_AAB001; --单位顺序号 V_SIC83.AAC001 := PI_AAC001; --个人顺序号 V_SIC83.AAE140 := PI_AAE140; --险种类型 V_SIC83.AAE341 := PI_AAE341; --筹资项目 V_SIC83.CAE230 := PI_CAE230; --账户变动类型 V_SIC83.CAE178 := PI_CAE178; --收支标志: --将入参赋值给v_zhbgmx,数据类型为二类数据,计息标志为不计息 V_SIC83.CAE682 := PI_CAE682; V_SIC83.CAA034 := V_LXJSBZ_BJS; --计息标志,不计息 V_SIC83.CAE233 := NVL(PI_CAE233, TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘))); --账户写入日期:记录产生的系统日期 V_SIC83.CAE231 := PI_CAE231; --业务关键字段 V_SIC83.CAE232 := PI_CAE232; --业务关键字段值 V_SIC83.CAE177 := V_SZFS_ZXJF; V_SIC83.CAE178 := PI_CAE178; --收支标志 V_SIC83.CAE683 := NVL(PI_CAE233, TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘))); --财务确认时间,暂时用cae233代替 V_SIC83.CAE684 := 0; V_SIC83.AAA031 := 0; --收支类型=支出? --将所有金额变成负数 IF PI_CAE178 = V_SZBZ_ZC THEN V_SIC83.AAC123 := 0 - NVL(PI_AAC123, 0); --个人缴费金额 V_SIC83.AAC125 := 0 - NVL(PI_AAC125, 0); --划入账户金额 V_SIC83.AAC127 := 0 - NVL(PI_AAC127, 0); --划入统筹金额 ELSE V_SIC83.AAC123 := NVL(PI_AAC123, 0); --个人缴费金额 V_SIC83.AAC125 := NVL(PI_AAC125, 0); --划入账户金额 V_SIC83.AAC127 := NVL(PI_AAC127, 0); --划入统筹金额 END IF; --szn 20111213 modify V_SIC83.CAC074 := V_SIC83.AAC123; V_SIC83.CAC075 := V_SIC83.AAC125; -- a 20120217 add 用户问题报告CS_120210_008中发现办理的参保历史正常的收支明细,备注信息没有写到SIC83 -- 将入参中的备注字段增加到收支明细 V_SIC83.AAE013 := PI_AAE013; --调用养老账户变更明细_生成方法生成养老帐户变更明细 YLZHBGMX_SC(V_SIC83, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_qtys_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_qtys"时系统错误,传入参数为:‘ || ‘pi_aab001:‘ || PI_AAB001 || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END YLZHBGMX_QTYS; --养老账户变更明细_待遇支付 PROCEDURE YLZHBGMX_DYZF(PI_AAC001 IN NUMBER, --人员ID PI_AAB001 IN NUMBER, --组织ID PI_BAE001 IN VARCHAR2, --系统机构代码 PI_AAZ220 IN NUMBER, --待遇支付顺序号 PI_AAA076 IN VARCHAR2, --待遇类型 PI_AAE145 IN VARCHAR2, --待遇发放方式 PI_AAE140 IN VARCHAR2, --险种类型 PI_AAC123 IN NUMBER, --个人支付金额 PI_AAC125 IN NUMBER, --单位账户支付金额 PI_AAC127 IN NUMBER, --单位统筹支付金额 PI_CAE230 IN VARCHAR2, --账户变动类型 PI_AAE013 IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_SIC83 SIC83%ROWTYPE; V_SZBZ_ZC SIC83.CAE178%TYPE; --收支标志_支出 V_SJLX_YLSJ SIC83.CAE682%TYPE; --综合参数_数据类型_一类数据 V_LXJSBZ_JS SIC83.CAA034%TYPE; --综合参数_利息计算标志_计算 V_SZFS_ZXJF SIC83.CAE177%TYPE; V_ZHBDLX_DYZF SIC83.CAE230%TYPE; BEGIN PO_FHZ := ‘1‘; V_ZHBDLX_DYZF := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘DYZF‘); V_SJLX_YLSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘YLSJ‘); --获取综合参数数据类型_一类数据 V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_SZFS_ZXJF := PKG_FUN.F_GET_DICT(‘CAE177‘, ‘ZXJF‘); V_SZBZ_ZC := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘ZC‘); --将入参赋值给v_zhbgmx,数据类型为一类数据,计息标志为计息,关键字段为待遇支付顺序号 V_SIC83.BAE001 := PI_BAE001; --系统机构代码 V_SIC83.AAB001 := PI_AAB001; --单位顺序号 V_SIC83.AAC001 := PI_AAC001; --个人顺序号 V_SIC83.AAE140 := PI_AAE140; --险种类型 V_SIC83.AAE341 := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCJF‘); --筹资项目 目前没设置 ,按同步养老账户余额的代码来看,应该为正常缴费 V_SIC83.CAE230 := PI_CAE230; --账户变动类型 V_SIC83.CAE177 := V_SZFS_ZXJF; V_SIC83.CAE178 := V_SZBZ_ZC; --收支标志 V_SIC83.CAE682 := V_SJLX_YLSJ; --数据类型为一类数据(默认) V_SIC83.CAA034 := V_LXJSBZ_JS; --计息标志(默认计息) V_SIC83.CAE233 := TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘)); --账户写入日期:记录产生的系统日期 V_SIC83.CAE231 := ‘AAZ220‘; --业务关键字段 待遇支付顺序号 V_SIC83.CAE232 := PI_AAZ220; --业务关键字段值 V_SIC83.CAE684 := 0; --上年度利息,暂时定为0,未定利息计算方式 V_SIC83.AAA031 := 0; --利率 --帐户变更类型=待遇支付? IF PI_CAE230 = V_ZHBDLX_DYZF THEN --将所有金额变成负数 V_SIC83.AAC123 := 0 - NVL(PI_AAC123, 0); --个人缴费金额 V_SIC83.AAC125 := 0 - NVL(PI_AAC125, 0); --划入账户金额 V_SIC83.AAC127 := 0 - NVL(PI_AAC127, 0); --划入统筹金额 ELSE V_SIC83.AAC123 := NVL(PI_AAC123, 0); --个人缴费金额 V_SIC83.AAC125 := NVL(PI_AAC125, 0); --划入账户金额 V_SIC83.AAC127 := NVL(PI_AAC127, 0); --划入统筹金额 END IF; --szn 20111213 modify V_SIC83.CAC074 := V_SIC83.AAC123; V_SIC83.CAC075 := V_SIC83.AAC125; --调用养老账户变更明细_生成方法生成养老帐户变更明细 YLZHBGMX_SC(V_SIC83, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_qtys_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_qtys"时系统错误,传入参数为:‘ || ‘pi_aab001:‘ || PI_AAB001 || ‘pi_aac001:‘ || PI_AAC001 || ‘,pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息:‘ || SQLERRM || ‘!‘; END YLZHBGMX_DYZF; --养老账户变更明细_转移信息 PROCEDURE YLZHBGMX_GRZYZL(PI_AAZ163 IN NUMBER, --个人变更记录号 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS /* a 2013.10.21 只取最后一年有账户的记录 2013.10.24 最后一年账户记录的账户金额必须大于0 2014.9.25 转入的账户年度以转入日期的年度为准 */ V_AC43 AC43%ROWTYPE; --行记录 V_SAC12 SAC12%ROWTYPE; V_SAC14 SAC14%ROWTYPE; V_CAE292 SAC12.CAE292%TYPE; V_CAE293 SAC12.CAE293%TYPE; V_DFYLZYBZ_ZY SAC12.CAE013%TYPE; V_STZHZYBZ_ZY SAC12.CAE012%TYPE; V_CZXM_ZCJF SIC83.AAE341%TYPE; V_ZHBDLX_SWZRZDFXYL SIC83.CAE230%TYPE; V_ZHBDLX_SWZRZST SIC83.CAE230%TYPE; V_SZBZ_ZC SIC83.CAE178%TYPE; --收支标志_支出 V_XZLX_DFYL SIC83.AAE140%TYPE; V_XZLX_JGYL SIC83.AAE140%TYPE; V_XZLX_QYYL SIC83.AAE140%TYPE; V_XZLX_SY SIC83.AAE140%TYPE; V_XZLX_JBYIL SIC83.AAE140%TYPE; V_YJLX_CXYTHGLBJ AC43.AAA115%TYPE; V_CAE230 SIC83.CAE230%TYPE; V_AAE013 SIC83.AAE013%TYPE; V_COUNT_ZH NUMBER; V_COUNT_DR NUMBER; V_NDZH NUMBER; V_ZHND NUMBER; ----转移账户年度 CURSOR C_SAC13 IS SELECT * FROM SAC13 WHERE AAZ163 = PI_AAZ163; PROCEDURE GET_SAC14_FOR_SIC86 IS V_BAE001 SAC14.BAE001%TYPE; V_AAE001 SAC14.AAE001%TYPE; V_AAC001 SAC14.AAC001%TYPE; V_AAB001 SAC14.AAB001%TYPE; V_AAE140 SAC14.AAE140%TYPE; V_AAE273_SN SAC14.AAE273%TYPE; V_AAC123_DN SAC14.AAC123%TYPE; V_AAE382_SN SAC14.AAE273%TYPE; V_AAE381_DN SAC14.AAC123%TYPE; --lewh 20150610 应急方案,非长久之道 BEGIN V_BAE001 := V_SAC12.BAE001; SELECT TO_NUMBER(SUBSTR(MAX(AAE041), 1, 4)) INTO V_AAE001 FROM SAC14 A WHERE A.AAZ163 = PI_AAZ163; V_AAC001 := V_SAC12.AAC001; V_AAB001 := V_SAC12.AAB001; V_AAE140 := V_SAC12.AAE140; SELECT NVL(MAX(AAE273), 0), NVL(MAX(AAE382), 0) INTO V_AAE273_SN, V_AAE382_SN FROM SAC14 A WHERE AAZ163 = PI_AAZ163 AND AAE041 LIKE SUBSTR(V_SAC12.AAE035, 1, 4) - 1 || ‘%‘; SELECT NVL(MAX(AAC123), 0), NVL(MAX(AAE381), 0) INTO V_AAC123_DN, V_AAE381_DN FROM SAC14 A WHERE AAZ163 = PI_AAZ163 AND AAE041 LIKE SUBSTR(V_SAC12.AAE035, 1, 4) || ‘%‘; V_SAC14.BAE001 := V_BAE001; V_SAC14.AAE001 := V_AAE001; V_SAC14.AAC001 := V_AAC001; V_SAC14.AAB001 := V_AAB001; V_SAC14.AAE140 := V_AAE140; V_SAC14.AAE273 := V_AAC123_DN + V_AAE273_SN; V_SAC14.AAE382 := V_AAE382_SN + V_AAE381_DN; END GET_SAC14_FOR_SIC86; BEGIN PO_FHZ := ‘1‘; V_CZXM_ZCJF := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCJF‘); --正常缴费 V_DFYLZYBZ_ZY := PKG_FUN.F_GET_DICT(‘CAE013‘, ‘ZY‘); V_STZHZYBZ_ZY := PKG_FUN.F_GET_DICT(‘CAE012‘, ‘ZY‘); V_ZHBDLX_SWZRZDFXYL := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZDFXYL‘); V_ZHBDLX_SWZRZST := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘SWZRZST‘); V_SZBZ_ZC := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘ZC‘); V_XZLX_DFYL := ‘DFYL‘; --yzy20130111 pkg_fun.f_get_dict(‘AAE140‘,‘DFYL‘); V_XZLX_JGYL := PKG_FUN.F_GET_DICT(‘AAE140‘, ‘JGYL‘); V_XZLX_QYYL := PKG_FUN.F_GET_DICT(‘AAE140‘, ‘QYYL‘); V_XZLX_SY := PKG_FUN.F_GET_DICT(‘AAE140‘, ‘SY‘); V_XZLX_JBYIL := PKG_FUN.F_GET_DICT(‘AAE140‘, ‘JBYIL‘); V_YJLX_CXYTHGLBJ := PKG_FUN.F_GET_DICT(‘AAA115‘, ‘CXYTHGLBJ‘); --根据pi_grbgjlh查询个人转移资料v_grzyzl(SAC12) FOR V_SAC13 IN C_SAC13 LOOP BEGIN SELECT * INTO V_SAC12 FROM SAC12 WHERE BAE007 = V_SAC13.BAE007 AND AAC001 = V_SAC13.AAC001 AND AAE140 = V_SAC13.AAE140; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grzyzl_01‘; PO_MSG := ‘个人变更记录号为:‘ || PI_AAZ163 || ‘的转移资料不存在,请核实‘; RETURN; WHEN TOO_MANY_ROWS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grzyzl_02‘; PO_MSG := ‘找到多条个人转移资料记录,传入参数:pi_aaz163=‘ || PI_AAZ163; RETURN; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grzyzl_09‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grzyzl"时系统错误,传入参数为:‘ || ‘pi_aaz163:‘ || PI_AAZ163 || ‘错误信息是:‘ || SQLERRM || ‘。‘; END; --ADD BY YANGYIXIN 增加转出账户变更明细处理 --转出后生成一条变更类型为支出的账户变更明细,同步账户余额为0 IF V_SAC13.CAE009 = C_CAE009_ZC THEN NULL; --生成账户变更明细 --ylzhbgmx_zcsw(pi_aaz163,v_SAC13,v_sac12.BHE949,po_fhz,po_msg) ; --modify by yangyixin 20120816 ,修改为在出账时调用 IF PO_FHZ != ‘1‘ THEN RETURN; END IF; ELSE --转入险种信息是否为企业养老信息?--机关养老和企业养老的处理方法一致,放置在一起处理 a 2013.5.16 IF V_SAC12.AAE140 IN (V_XZLX_QYYL, C_CAE230_SWZRZJG) THEN IF V_SAC12.AAE013 = ‘已下载的信息表导入‘ THEN --lewh 20150610 前人乱写的,现修正 V_COUNT_ZH := 1; GET_SAC14_FOR_SIC86; ELSE SELECT COUNT(1) INTO V_COUNT_ZH FROM SAC14 WHERE AAZ163 = PI_AAZ163 AND AAE001 = (SELECT MAX(AAE001) FROM SAC14 WHERE AAZ163 = PI_AAZ163) AND AAE382 > 0; SELECT * INTO V_SAC14 FROM SAC14 WHERE AAZ163 = PI_AAZ163 AND AAE001 = (SELECT MAX(AAE001) FROM SAC14 WHERE AAZ163 = PI_AAZ163) AND AAE382 > 0; END IF; IF V_COUNT_ZH > 1 THEN PO_FHZ := ‘-1‘; PO_MSG := ‘此人最后一年的转入信息录入错误,应只有一条记录记录其账户金额信息,请检查!‘; RETURN; END IF; IF V_COUNT_ZH = 0 THEN PO_FHZ := ‘-1‘; PO_MSG := ‘此人最后一年的转入信息录入错误,必需要有累计账户金额,且累计账户金额必须大于或等于转移账户金额,请检查!‘; RETURN; END IF; ----a 增加转移账户年度的判断 2014.9.25 IF NVL(SUBSTR(V_SAC12.AAE035, 1, 4), TO_CHAR(SYSDATE, ‘yyyy‘)) < V_SAC14.AAE001 THEN V_ZHND := V_SAC14.AAE001; ELSE V_ZHND := NVL(SUBSTR(V_SAC12.AAE035, 1, 4), TO_CHAR(SYSDATE, ‘yyyy‘)); END IF; IF V_SAC12.AAE140 = V_XZLX_QYYL THEN V_CAE230 := C_CAE230_SWZRZGRZH; V_AAE013 := ‘市外转入转企养二类冲减记录‘; ELSE V_CAE230 := C_CAE230_SWZRZJG; V_AAE013 := ‘市外转入转机关二类冲减记录‘; END IF; /*ylzhbgmx_qtys(v_SAC13.aab001,v_SAC13.aac001,v_SAC13.bae001,‘AAZ163‘,pi_aaz163, v_SAC13.aae140,V_CZXM_ZCJF,v_sac12.BHE949,NVL(v_sac13.AIC083,0),0,NVL(v_sac13.AIC084,0), C_CAE230_SWZRZGRZH,C_CAE178_SR,‘市外转入转企养二类冲减记录‘,po_fhz,po_msg);*/ YLZHBGMX_QTYS(V_SAC13.AAB001, V_SAC13.AAC001, V_SAC13.BAE001, ‘AAZ163‘, PI_AAZ163, V_SAC13.AAE140, V_CZXM_ZCJF, V_SAC12.BHE949, NVL(V_SAC14.AAE273, 0), (NVL(V_SAC14.AAE382, 0) - NVL(V_SAC14.AAE273, 0)), NVL(V_SAC13.AIC084, 0), V_CAE230, C_CAE178_SR, V_AAE013, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; ---生成转入的年度帐户记录 a20130516 --判断是否已有当天的转入帐户,若有则更新,没有则插入 SELECT COUNT(1) INTO V_NDZH FROM SIC86 WHERE AAC001 = V_SAC14.AAC001 AND NVL(AAE087, ‘0‘) = ‘1‘ AND AAE140 = V_SAC14.AAE140 AND AAE001 = NVL(SUBSTR(V_SAC12.AAE035, 1, 4), TO_CHAR(SYSDATE, ‘yyyy‘)) AND AAE035 = NVL(V_SAC12.AAE035, TO_CHAR(SYSDATE, ‘yyyymmdd‘)); ---防止同一天有两条转入记录的情况发生 a 20130521 ---插入或修改本年年度账户记录(这里不用计息,留到年末统一计息) IF V_NDZH = 0 THEN INSERT INTO SIC86 (BAE001, AAB001, AAC001, AAE001, AAE140, AAE087, AIC058, AIC072, AIC078, AIC079, AAE035) VALUES (V_SAC14.BAE001, V_SAC14.AAB001, V_SAC14.AAC001, V_ZHND, V_SAC14.AAE140, ‘1‘, (NVL(V_SAC14.AAE382, 0) - NVL(V_SAC14.AAE273, 0)), NVL(V_SAC14.AAE273, 0), (NVL(V_SAC14.AAE382, 0) - NVL(V_SAC14.AAE273, 0)), NVL(V_SAC14.AAE273, 0), NVL(V_SAC12.AAE035, TO_CHAR(SYSDATE, ‘yyyymmdd‘))); ELSE UPDATE SIC86 SET AIC058 = NVL(AIC058, 0) + (NVL(V_SAC14.AAE382, 0) - NVL(V_SAC14.AAE273, 0)), ---本年帐户单位缴费划拨部分本金(含补缴产生的划入利息) AIC072 = NVL(AIC072, 0) + NVL(V_SAC14.AAE273, 0), --本年个人缴纳 AIC078 = NVL(AIC078, 0) + (NVL(V_SAC14.AAE382, 0) - NVL(V_SAC14.AAE273, 0)), --单位划入累计金额 AIC079 = NVL(AIC079, 0) + NVL(V_SAC14.AAE273, 0) --个人缴纳累计金额(本金和利息) WHERE AAC001 = V_SAC14.AAC001 AND NVL(AAE087, ‘0‘) = ‘1‘ AND AAE140 = V_SAC14.AAE140 AND AAE001 = V_ZHND AND AAE035 = NVL(V_SAC12.AAE035, TO_CHAR(SYSDATE, ‘yyyymmdd‘)); END IF; -- a 20120411 解决问题报告CS_120329_063 ,转入的不能生成视同账户的收支明细,否则会将视同账户金额增加到养老账户中 /* IF v_sac12.cae012 = V_STZHZYBZ_ZY then --调用pkg_zhgl.ylzhmx_qtys生成变动类型为“市外转入转视同”的二类冲减记录 ylzhbgmx_qtys(v_SAC13.aab001,v_SAC13.aac001,v_SAC13.bae001,‘AAZ163‘,pi_aaz163, v_SAC13.aae140,V_CZXM_ZCJF,v_sac12.BHE949,NVL(v_sac13.CAC020,0),0,0, C_CAE230_SWZRZST,C_CAE178_SR,‘市外转入转视同二类冲减记录‘,po_fhz,po_msg); IF po_fhz != ‘1‘ THEN RETURN; END IF ; END IF; */ -- 如果地方养老金大于0则同步地方养老账户 /* IF NVL(v_sac13.CAC017,0) > 0 THEN --调用pkg_zhgl.ylzhmx_qtys生成变动类型为“市外转入转地方”的二类冲减记录 ylzhbgmx_qtys(v_SAC13.aab001,v_SAC13.aac001,v_SAC13.bae001,‘AAZ163‘,pi_aaz163, pkg_fun.f_get_dict(‘AAE140‘,‘DFYL‘),V_CZXM_ZCJF,v_sac12.BHE949,NVL(v_sac13.CAC017,0),0,0, C_CAE230_SWZRZDFXYL,C_CAE178_SR,‘市外转入转地方二类冲减记录‘,po_fhz,po_msg); IF po_fhz != ‘1‘ THEN RETURN; END IF; END IF; */ END IF; --V_grzyzl中是否转入机关养老信息? /* IF v_sac12.aae140 = V_XZLX_JGYL THEN --调用pkg_zhgl.ylzhmx_qtys生成变动类型为“市外转入转机关”的二类冲减记录 --调用pkg_zhgl.ylzhmx_qtys生成变动类型为“市外转入转地方”的二类冲减记录 ylzhbgmx_qtys(v_SAC13.aab001,v_SAC13.aac001,v_SAC13.bae001,‘AAZ163‘,pi_aaz163, v_SAC13.aae140,V_CZXM_ZCJF,v_sac12.BHE949,NVL(v_sac13.AIC083,0),0,NVL(v_sac13.AIC084,0), C_CAE230_SWZRZJG,C_CAE178_SR,‘市外转入转机关二类冲减记录‘,po_fhz,po_msg); IF po_fhz != ‘1‘ THEN RETURN; END IF; END IF; */ /* -- a 20120106 modify 医疗和失业不需要生成收支明细吧 --是否转入医疗信息 IF SUBSTR(v_sac12.aae140,1,1) = SUBSTR(V_XZLX_JBYIL,1,1) THEN --调用pkg_zhgl.ylzhmx_qtys生成变动类型为“市外转入转医疗”的二类冲减记录 ylzhbgmx_qtys(v_sac12.aab001,v_sac12.aac001,v_sac12.bae001,‘AAZ163‘,pi_aaz163,v_sac12.aae140,V_CZXM_ZCJF, v_sac12.AAE036,v_sac13.CAC020,0,0,V_ZHBDLX_SWZRZST,V_SZBZ_ZC,‘市外转入转医疗二类冲减记录‘,po_fhz,po_msg); IF po_fhz != ‘1‘ THEN RETURN; END IF; END IF; --是否转入失业信息 IF SUBSTR(v_sac12.aae140,1,1) = SUBSTR(V_XZLX_SY,1,1) THEN --调用pkg_zhgl.ylzhmx_qtys生成变动类型为“市外转入转失业”的二类冲减记录 ylzhbgmx_qtys(v_sac12.aab001,v_sac12.aac001,v_sac12.bae001,‘AAZ163‘,pi_aaz163,v_sac12.aae140,V_CZXM_ZCJF, v_sac12.AAE036,v_sac13.CAC020,0,0,V_ZHBDLX_SWZRZST,V_SZBZ_ZC,‘市外转入转失业二类冲减记录‘,po_fhz,po_msg); IF po_fhz != ‘1‘ THEN RETURN; END IF; END IF; */ END IF; END LOOP; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grzyzl_98‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grzyzl"时找不到相关信息,传入参数为:‘ || ‘pi_aaz163:‘ || PI_AAZ163 || ‘错误信息是:‘ || SQLERRM || ‘。‘; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_grzyzl_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_grzyzl"时系统错误,传入参数为:‘ || ‘pi_aaz163:‘ || PI_AAZ163 || ‘错误信息是:‘ || SQLERRM || ‘。‘; END YLZHBGMX_GRZYZL; --养老账户变更明细_补录历史(Ylzhbgmx_blls) PROCEDURE YLZHBGMX_BLLS(PI_CAE125 IN NUMBER, --台帐变更记录号 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_AC43 AC43%ROWTYPE; V_ZHBDLX_ARSZDBL SIC83.CAE230%TYPE; --资料补录 V_CZXM_ZCJF SIC83.AAE341%TYPE; V_SZBZ_SR SIC83.CAE178%TYPE; --收支标志_收入 V_YJLX_CXYTHGLBJ AC43.AAA115%TYPE; V_LXJSBZ_JS SIC83.CAA034%TYPE; --综合参数_利息计算标志_计算 V_LXJSBZ_BJS SIC83.CAA034%TYPE; --综合参数_利息计算标志_不计算 V_SJLX_YLSJ SIC83.CAE682%TYPE; --综合参数_数据类型_一类数据 V_SJLX_ELSJ SIC83.CAE682%TYPE; --综合参数_数据类型_二类数据 V_SZBZ_ZC SIC83.CAE178%TYPE; --收支标志_支出 V_SZFS_ZXJF SIC83.CAE177%TYPE; CURSOR C_AC43 IS SELECT * FROM AC43 WHERE CAE125 = PI_CAE125; BEGIN PO_FHZ := ‘1‘; V_ZHBDLX_ARSZDBL := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘ARSZDBL‘); V_CZXM_ZCJF := PKG_FUN.F_GET_DICT(‘AAE341‘, ‘ZCJF‘); --正常缴费 V_SZBZ_ZC := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘ZC‘); V_SZBZ_SR := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘SR‘); V_YJLX_CXYTHGLBJ := PKG_FUN.F_GET_DICT(‘AAA115‘, ‘CXYTHGLBJ‘); V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_LXJSBZ_BJS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘BJS‘); --获取利息计算标志_不计算的综合参数 V_SJLX_YLSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘YLSJ‘); --获取综合参数数据类型_一类数据 V_SJLX_ELSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘ELSJ‘); --获取综合参数数据类型_二类数据 FOR V_GRYJ IN C_AC43 LOOP --调用养老账户变更明细_其他应收转换生成帐户变动类型为“资料补录”的冲减的二类数据记录,计息标志为不计息 YLZHBGMX_QTYS(V_GRYJ.AAB001, --组织ID V_GRYJ.AAC001, --人员ID V_GRYJ.BAE001, --系统机构代码 ‘CAE125‘, --业务关键字段 PI_CAE125, --业务关键字段值 V_GRYJ.AAE140, --险种类型 V_GRYJ.AAE341, --筹资项目 TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘)), --账户写入时间 V_GRYJ.AAC123, --个人缴费金额 V_GRYJ.AAC125, --划入账户金额 V_GRYJ.AAC127, --划入统筹金额 V_ZHBDLX_ARSZDBL, --账户变动类型_按人数征收补录(资料补录) V_SZBZ_ZC, --收支类型 V_GRYJ.AAE013, --备注 PO_FHZ, --返回值 PO_MSG --返回消息 ); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --调用养老账户变更明细_个人应缴转换生成帐户变动类型为“资料补录”的一类数据记录,计息标志为计息 YLZHBGMX_GRYJ(V_GRYJ, --行记录 ‘CAE125‘, --业务关键字段 PI_CAE125, --业务关键字段值 V_ZHBDLX_ARSZDBL, --账户变动类型 V_GRYJ.AAE013, --备注, PO_FHZ, --返回值 PO_MSG --返回消息 ); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END LOOP; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_blls_98‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_blls"时找不到相关信息,传入参数为:‘ || ‘pi_cae125:‘ || PI_CAE125 || ‘错误信息是:‘ || SQLERRM || ‘。‘; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_blls_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_blls"时系统错误,传入参数为:‘ || ‘pi_cae125:‘ || PI_CAE125 || ‘错误信息是:‘ || SQLERRM || ‘。‘; END YLZHBGMX_BLLS; --养老个人帐户_帐户人员合并 PROCEDURE YLZHBGMX_RYHB(PI_AAZ163 IN NUMBER, --个人变更记录号 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_AC23 AC23%ROWTYPE; V_ZHBDLX_RYHB SIC83.CAE230%TYPE; --资料补录 BEGIN --将被合并人的养老账户明细合并到合并人(个人顺序号、合并业务流水号) --查询个人变更记录 BEGIN SELECT * INTO V_AC23 FROM AC23 WHERE AAZ163 = PI_AAZ163; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_ryhb_01‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_ryhb"时找不到相关信息,传入参数为:‘ || ‘pi_aaz163:‘ || PI_AAZ163 || ‘错误信息是:‘ || SQLERRM || ‘。‘; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_ryhb_02‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_ryhb"时系统错误,传入参数为:‘ || ‘pi_aaz163:‘ || PI_AAZ163 || ‘错误信息是:‘ || SQLERRM || ‘。‘; END; V_ZHBDLX_RYHB := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘RYHB‘); --将被合并人的ys_ylzhmx合并到合并人 --原表有hbywlsh,但核三表已经进行取消。 --放业务关键字段,可能导致抹去原有记录字段信息。 UPDATE SIC83 SET AAC001 = V_AC23.AAC001, CAE231 = ‘BAE007‘, CAE232 = V_AC23.BAE007 WHERE AAC001 = V_AC23.CAC038; --养老账户明细_计息:计算日期是否取个人变更记录中的bgrq --调用养老个人帐户计息方法重新计算利息 PKG_ZHGL.YLZHMX_JX(V_AC23.AAC001, V_ZHBDLX_RYHB, V_AC23.AAE036, V_AC23.AAE011, V_AC23.AAE013, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_ryhb_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_ryhb"时系统错误,传入参数为:‘ || ‘pi_aaz163:‘ || PI_AAZ163 || ‘错误信息是:‘ || SQLERRM || ‘。‘; END YLZHBGMX_RYHB; --养老账户变更明细_财务确认(Ylzhbgmx_cwqr) PROCEDURE YLZHBGMX_CWQR(PI_CAE231 IN VARCHAR2, --业务关键字段 PI_CAE232 IN NUMBER, --业务关键字段值 PI_CWQRSJ IN DATE, --财务确认时间 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_SIC83 SIC83%ROWTYPE; BEGIN PO_FHZ := ‘1‘; --根据业务关键字段和关键字段值判断是否存在帐户变更记录,不存在则抛出异常 --20120105 jinqingyu 注释 /* SELECT count(1) INTO v_sic83 FROM SIC83 WHERE CAE231 = pi_cae231 AND CAE232 = pi_cae232 ; */ --根据业务关键字段和关键字段值更新财务到账时间 UPDATE SIC83 SET CAE683 = TO_NUMBER(TO_CHAR(PI_CWQRSJ, ‘yyyymmdd‘)) WHERE CAE231 = PI_CAE231 AND CAE232 = PI_CAE232; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_cwqr_01‘; PO_MSG := ‘业务关键字段pi_cae231为:‘ || PI_CAE231 || ‘的帐户变更记录不存在,请核实‘; RETURN; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_cwqr_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_cwqr"时系统错误,传入参数为:‘ || ‘pi_cae231:‘ || PI_CAE231 || ‘pi_cae232:‘ || PI_CAE232 || ‘错误信息是:‘ || SQLERRM || ‘。‘; END YLZHBGMX_CWQR; --养老账户变更明细_月积数法计息 PROCEDURE YLZHBGMX_YJSFJX(PI_AAC001 IN NUMBER, --个人顺序号 PI_AAE140 IN VARCHAR2, --险种类型 PI_JSRQ IN DATE, --计算日期 PO_GRLX OUT NUMBER, --个人部分利息 PO_DWLX OUT VARCHAR2, --单位部分利息 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_GRJFLX NUMBER(16, 2); V_HRTCLX NUMBER(16, 2); V_HRZHLX NUMBER(16, 2); V_GRJFJE NUMBER(16, 2); V_HRTCJE NUMBER(16, 2); V_HRZHJE NUMBER(16, 2); V_GRJXBJ NUMBER(16, 2); --个人计息本金 V_DWJXBJ NUMBER(16, 2); --单位划入计息本金 V_DWLX NUMBER(16, 2) := 0; V_GRLX NUMBER(16, 2) := 0; V_QSRQ DATE; V_LXJSBZ_JS SIC83.CAA034%TYPE; V_SJLX_YLSJ SIC83.CAE682%TYPE; V_ZHBDLX_NZJX SIC83.CAE230%TYPE; V_ZHBDLX_NDJX SIC83.CAE230%TYPE; V_SPBZ_YSP AA03.BCE326%TYPE; V_KSRQ NUMBER; V_ZZRQ NUMBER; --计息险种 CURSOR C_SIC83 IS SELECT * FROM SIC83 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND CAA034 = V_LXJSBZ_JS AND CAE682 = V_SJLX_YLSJ AND CAE233 <= TO_NUMBER(TO_CHAR(PI_JSRQ, ‘yyyymmddhhmmss‘)) AND CAE683 IS NOT NULL --财务已经确认 ORDER BY CAE683 --原设计为所属年月,但无所属年月字段 ; BEGIN PO_FHZ := ‘1‘; V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_SJLX_YLSJ := PKG_FUN.F_GET_DICT(‘CAE682‘, ‘YLSJ‘); --获取综合参数数据类型_一类数据 V_ZHBDLX_NZJX := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NZJX‘); V_ZHBDLX_NDJX := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NDJX‘); V_SPBZ_YSP := PKG_FUN.F_GET_DICT(‘BCE326‘, ‘YSP‘); FOR V_SIC83 IN C_SIC83 LOOP --账户变动类型=计息? IF V_SIC83.CAE230 IN (V_ZHBDLX_NZJX, V_ZHBDLX_NDJX) THEN V_GRJXBJ := NVL(V_SIC83.CAC074, 0) + NVL(V_SIC83.CAC076, 0); V_DWJXBJ := NVL(V_SIC83.CAC075, 0) + NVL(V_SIC83.CAC077, 0); V_QSRQ := TO_DATE(SUBSTR(V_SIC83.CAE234, 1, 6), ‘YYYYmm‘); --计息起始日期:取资金变动日期 ELSE --计息本金=本次变动金额,本次计算只取本金,已产生的利息不包括在内 V_GRJXBJ := NVL(V_SIC83.AAC123, 0); V_DWJXBJ := NVL(V_SIC83.AAC125, 0); V_QSRQ := TO_DATE(SUBSTR(V_SIC83.CAE233, 1, 6), ‘yyyymm‘); --计息起始日期:取财务确认时间(原来取缴费所属年月) END IF; --调用yjsjx计算利息,此过程根据gryj_jsqklx4独立 PKG_YSHD.GET_LX_BY_YJS(V_SIC83.BAE001, V_GRJXBJ, V_DWJXBJ, 0, V_QSRQ, TO_DATE(SUBSTR(PI_JSRQ, 1, 6), ‘yyyymm‘), V_GRJFLX, V_HRZHLX, V_HRTCLX, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --合计利息,不是年终或年度计息时需减去之前产生的利息 IF V_SIC83.CAE230 NOT IN (V_ZHBDLX_NZJX, V_ZHBDLX_NDJX) THEN V_GRJFLX := NVL(V_GRJFLX, 0) - NVL(V_SIC83.AAC124, 0); V_HRZHLX := NVL(V_HRZHLX, 0) - NVL(V_SIC83.AAC126, 0); END IF; V_GRLX := NVL(V_GRLX, 0) + NVL(V_GRJFLX, 0); V_DWLX := NVL(V_DWLX, 0) + NVL(V_HRZHLX, 0); END LOOP; PO_DWLX := V_DWLX; PO_GRLX := V_GRLX; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_YLZHGL.YLZHbgMC_JX_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_YLZHGL.YLZHbgMC_JX"时系统错误,传入参数:pi_aac001=‘ || PI_AAC001 || ‘,pi_jsrq=‘ || TO_CHAR(PI_JSRQ, ‘yyyy-mm-dd‘) || ‘;系统错误信息是:‘ || SQLERRM || ‘;调用栈是:‘ || DBMS_UTILITY.FORMAT_CALL_STACK || ‘。‘; END YLZHBGMX_YJSFJX; --养老账户变更明细_计息(Ylzhmx_jx) PROCEDURE YLZHMX_JX(PI_AAC001 IN NUMBER, --个人顺序号 PI_JSRQ IN DATE, --计算日期 PI_ZHBDLX IN VARCHAR2, --账户变动类型 PI_AAE011 IN NUMBER, --经办人 PI_AAE013 IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2) --返回消息 IS /*-- 变量声明 -------*/ V_COUNT NUMBER; V_DWLX_YJSF NUMBER(10, 2); --单位划入利息_月积数法 V_GRLX_YJSF NUMBER(10, 2); --个人缴费利息_月积数法 V_DWLX_YFLF NUMBER(10, 2); --单位划入利息_月复利法 V_GRLX_YFLF NUMBER(10, 2); --个人缴费利息_月复利法 V_SIC83 SIC83%ROWTYPE; V_SIC81 SIC81%ROWTYPE; V_SHNY NUMBER; V_LXJSBZ_JS SIC83.CAA034%TYPE; V_SZBZ_SR SIC83.CAE178%TYPE; V_LXJSBZ_BJS SIC83.CAA034%TYPE; V_ZHBDLX_NZJX SIC83.CAE230%TYPE; V_ZHBDLX_NDJX SIC83.CAE230%TYPE; --计息险种 CURSOR C_JXXZ IS SELECT DISTINCT AAE140 FROM SIC83 WHERE AAC001 = PI_AAC001 AND CAA034 = V_LXJSBZ_JS AND CAE683 IS NOT NULL; BEGIN V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_SZBZ_SR := PKG_FUN.F_GET_DICT(‘CAE178‘, ‘SR‘); V_LXJSBZ_JS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘JS‘); --获取利息计算标志_计算的综合参数 V_LXJSBZ_BJS := PKG_FUN.F_GET_DICT(‘CAA034‘, ‘BJS‘); --获取利息计算标志_不计算的综合参数 V_ZHBDLX_NZJX := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NZJX‘); V_ZHBDLX_NDJX := PKG_FUN.F_GET_DICT(‘CAE230‘, ‘NDJX‘); FOR V_JXXZ IN C_JXXZ LOOP --调用月积数计息方法计算帐户利息 YLZHBGMX_YJSFJX(PI_AAC001, V_JXXZ.AAE140, PI_JSRQ, V_GRLX_YFLF, V_DWLX_YJSF, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --查询养老个人账户信息 BEGIN SELECT * INTO V_SIC81 FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = V_JXXZ.AAE140; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL.SIc81_CX_01‘; PO_MSG := ‘个人顺序号为:‘ || PI_AAC001 || ‘,险种类型为:‘ || V_JXXZ.AAE140 || ‘的个人帐户不存在!‘; RETURN; WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.SIc81_CX_99‘; PO_MSG := ‘调用"PKG_ZHGL.SIc81_CX"时系统错误,传入参数为:‘ || ‘pi_aac001:‘ || PI_AAC001 || ‘;pi_aae140:‘ || V_JXXZ.AAE140 || ‘;系统错误信息是:‘ || SQLERRM || ‘。‘; END; --确定审核年月 PKG_PUB.GETSHNYXY(V_SIC81.BAE001, V_SHNY, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_SHNY := SUBSTR(TO_CHAR(V_SHNY), 1, 6); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_SIC83.BAE001 := V_SIC81.BAE001; --系统机构代码 V_SIC83.AAB001 := V_SIC81.AAB001; --单位顺序号 V_SIC83.AAC001 := PI_AAC001; --个人顺序号 V_SIC83.AAE140 := V_JXXZ.AAE140; --险种类型 V_SIC83.CAE683 := TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘)); --财务确认时间 --sic83.tzny := v_shny;--台帐年月 V_SIC83.CAE230 := PI_ZHBDLX; --账户变动类型 V_SIC83.CAE178 := V_SZBZ_SR; --收支标志:收入 V_SIC83.CAA034 := V_LXJSBZ_JS; --计息标志 V_SIC83.CAE233 := TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘)); --账户写入日期:记录产生的系统日期 V_SIC83.AAC123 := 0; V_SIC83.AAC127 := 0; V_SIC83.AAC125 := 0; V_SIC83.AAC128 := 0; V_SIC83.AAC124 := NVL(V_GRLX_YFLF, 0) + NVL(V_GRLX_YJSF, 0); V_SIC83.AAC126 := NVL(V_DWLX_YFLF, 0) + NVL(V_DWLX_YJSF, 0); --szn 20111213 modify V_SIC83.CAC074 := V_SIC83.AAC123; V_SIC83.CAC075 := V_SIC83.AAC125; V_SIC83.CAC076 := V_SIC83.AAC124; V_SIC83.CAC077 := V_SIC83.AAC126; --修改本次计息范围内的记录:计算标志=‘不计息‘,帐户计息日期=‘v_ylzhmx.zhxrrq‘ UPDATE SIC83 SET CAA034 = V_LXJSBZ_BJS, CAE234 = V_SIC83.CAE233 WHERE AAC001 = PI_AAC001 AND AAE140 = V_JXXZ.AAE140 AND CAA034 = V_LXJSBZ_JS AND CAE683 = TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmddhhmmss‘)); --生成此次计息的ys_ylzhmx记录 PKG_ZHGL.YLZHBGMX_SC(V_SIC83, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --将本年金额结转到累计金额字段,并清空本年金额字段 UPDATE SIC81 SET CAC046 = NVL(CAC046, 0) + NVL(AAE262, 0), AAE256 = NVL(AAE256, 0) + NVL(AAE263, 0), CAC047 = NVL(CAC047, 0) + NVL(AAE264, 0), AAE257 = NVL(AAE257, 0) + NVL(AAE265, 0), AAE262 = 0, AAE263 = 0, AAE264 = 0, AAE265 = 0 WHERE AAC001 = PI_AAC001 AND AAE140 = V_JXXZ.AAE140; END LOOP; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhmx_jx_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhmx_jx"时系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END; --养老账户变更明细_养老个人帐户重算 --暂缺 PROCEDURE YLZHBGMX_YLGRZHCS(PI_AAC001 IN NUMBER, --个人顺序号 PI_AAE140 IN DATE, --计算日期 PI_AAE011 IN NUMBER, --经办人 PI_AAE013 IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2) --返回消息 IS BEGIN PO_FHZ := ‘1‘; NULL; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_ylgrzhcs_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_ylgrzhcs"时系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YLZHBGMX_YLGRZHCS; --账户管理_帐户年度处理(zhgl_zhndcl) PROCEDURE ZHGL_ZHNDCL(PI_BAE001 IN NUMBER, --个人顺序号 PI_JXRQ IN DATE, --计算日期 PI_AAE011 IN NUMBER, --经办人 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2) --返回消息 IS /*-- 变量声明 ----------------------------------------------------------*/ V_BAE001 AC01.BAE001%TYPE; V_AAE140 AA08.AAE140%TYPE; V_LX NUMBER; V_SHRQ NUMBER; V_LASTSHNY NUMBER; V_COUNT NUMBER; V_SHLX_N SAE02.CAA020%TYPE; V_JLZHBZ_S VARCHAR2(6); V_XZLX_QYYL AC02.AAE140%TYPE; V_XZLX_JBYIL AC02.AAE140%TYPE; /*-- CURSOR声明 --------------------------------------------------------*/ CURSOR C_JGSZ IS SELECT BAE001 FROM SAE02 WHERE (BAE001 = PI_BAE001 OR PI_BAE001 = ‘0‘) AND CAA020 = V_SHLX_N AND CAA021 >= V_LASTSHNY || ‘01‘ AND CAA021 <= V_LASTSHNY || ‘31‘ FOR UPDATE NOWAIT; CURSOR C_XZSZ IS SELECT AAE140 FROM AA08 WHERE AAE140 IN (‘0‘, V_AAE140) AND AAA008 = V_JLZHBZ_S; BEGIN V_LASTSHNY := TO_CHAR(ADD_MONTHS(TO_DATE(SUBSTR(PI_JXRQ, 1, 6), ‘yyyymm‘), -12), ‘yyyymm‘); V_COUNT := 0; V_SHLX_N := PKG_FUN.F_GET_DICT(‘CAA020‘, ‘N‘); V_JLZHBZ_S := PKG_FUN.F_GET_DICT(‘AAA008‘, ‘S‘); V_XZLX_QYYL := PKG_FUN.F_GET_DICT(‘AAE140‘, ‘QYYL‘); V_XZLX_JBYIL := PKG_FUN.F_GET_DICT(‘AAE140‘, ‘JBYIL‘); FOR V_JGSZ IN C_JGSZ LOOP V_BAE001 := V_JGSZ.BAE001; V_COUNT := 1; FOR V_XZSZ IN C_XZSZ LOOP V_AAE140 := V_XZSZ.AAE140; IF SUBSTR(V_AAE140, 1, 1) = SUBSTR(V_XZLX_QYYL, 1, 1) THEN -- 养老帐户 YLGRZH_ZHNDCL(V_BAE001, V_AAE140, TO_NUMBER(TO_CHAR(PI_JXRQ, ‘yyyymmdd‘)), PI_AAE011, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; ELSIF SUBSTR(V_AAE140, 1, 1) = SUBSTR(V_XZLX_JBYIL, 1, 1) THEN -- 医疗帐户 -- ybgrzh_zhndcl( v_bae001, TO_NUMBER(TO_CHAR(pi_jxrq,‘yyyymmdd‘)), pi_aae011, po_fhz, po_msg ); -- IF po_fhz != ‘1‘ THEN -- RETURN; -- END IF; NULL; END IF; END LOOP; --v_shrq:=pkg_pub.qdxtrq(); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --调用月结包生成审核类型为"年"的审核日期,待完善 --pkg_yj.shrq_sc( v_bae001, V_SHLX_N, v_shrq, -- pi_aae011, po_fhz, po_msg ); --IF po_fhz != ‘1‘ THEN -- RETURN; --END IF; END LOOP; IF V_COUNT = 0 THEN PO_FHZ := ‘pkg_ZHGL_050‘; PO_MSG := ‘没有可办理年度审核的a机构,请检查审核日期是否正确!‘; ELSE PO_FHZ := ‘1‘; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.zhgl_zhndcl_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.zhgl_zhndcl"时系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END ZHGL_ZHNDCL; --医疗帐户配置明细_生成 PROCEDURE YILZHPZMX_SC(PI_AAC001 IN NUMBER, --人员ID PI_AAB001 IN NUMBER, --组织ID PI_BAE001 IN VARCHAR2, --系统机构代码 PI_AAE140 IN VARCHAR2, --险种类型 PI_CAC037 IN NUMBER, --配置金额 PI_CAC044 IN NUMBER, --配置单位金额 PI_CAC045 IN NUMBER, --配置个人金额 PI_CAE320 IN NUMBER, --缴费顺序号 PI_AAE003 IN NUMBER, --缴费年月 PI_AAE011 IN VARCHAR2, --经办人 PI_AAE013 IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_CAE156 SKC82.CAE156%TYPE; BEGIN PO_FHZ := ‘1‘; --生成账户配置顺序号 SELECT SEQ_BXGX_CAE156.NEXTVAL INTO V_CAE156 FROM DUAL; --生成帐户配置明细 INSERT INTO SKC82 (CAE156, BAE001, AAB001, AAC001, AAE140, CAC037, CAC044, CAC045, AAE011, CAE320, AAE003, AAE013, CAE171, CAE128) VALUES (V_CAE156, PI_BAE001, PI_AAB001, PI_AAC001, PI_AAE140, PI_CAC037, PI_CAC044, PI_CAC045, PI_AAE011, PI_CAE320, PI_AAE003, PI_AAE013, C_CAE171_DBP, PKG_FUN.F_GET_SYSDATE(14)); BEGIN ---修改个人账户余额(a 2013.5.9) UPDATE SKC81 SET AAE262 = NVL(AAE262, 0) + NVL(PI_CAC044, 0), AAE264 = NVL(AAE264, 0) + NVL(PI_CAC045, 0), AAE240 = NVL(AAE240, 0) + NVL(PI_CAC037, 0) WHERE AAC001 = PI_AAC001; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO SKC81 --医保个人帐户@医保个人帐户信息 (BAE001, --a机构 AAB001, --组织ID@组织编号:组织唯一标识,系统生成。 AAC001, --人员ID CAE246, --帐户状态@正常、注销、暂时封存 AAE252, --上年医疗帐户结转金额 CAC078, --上年医疗帐户结转利息 CAC079, --转入或继承金额 AAE262, --本年单位划入 AAE264, --本年个人缴纳 CAC080, --本年补充医疗计入 AAE240) --医疗帐户余额 VALUES (PI_BAE001, --a机构 PI_AAB001, --组织ID@组织编号:组织唯一标识,系统生成。 PI_AAC001, --人员ID ‘1‘, --帐户状态@正常、注销、暂时封存 0, --上年医疗帐户结转金额 0, --上年医疗帐户结转利息 0, --转入或继承金额 PI_CAC044, --本年单位划入 PI_CAC045, --本年个人缴纳 0, --本年补充医疗计入 PI_CAC037); --医疗帐户余额 WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.YILZHPZMX_SC_09‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.YILZHPZMX_SC"修改医保个人账户时系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; RETURN; END; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.YILZHPZMX_SC_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.YILZHPZMX_SC"时系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YILZHPZMX_SC; --养老个人账户_帐户年度处理 PROCEDURE YLGRZH_ZHNDCL(PI_BAE001 IN VARCHAR2, --系统机构代码 PI_AAE140 IN VARCHAR2, --险种类型 PI_JXRQ IN NUMBER, --计息日期 PI_AAE011 IN NUMBER, --经办人 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS /*-- 变量声明 ----------------------------------------------------------*/ V_ND NUMBER(8); V_SHNY SAE02.CAA021%TYPE; --审核年月 V_ZHZT_ZC SIC81.CAE246%TYPE; V_ZHZT_ZX SIC81.CAE246%TYPE; -- 养老个人帐户 CURSOR C_YLGRZH IS SELECT * FROM SIC81 WHERE BAE001 = PI_BAE001 AND AAE140 = PI_AAE140 AND CAE246 != V_ZHZT_ZC; BEGIN --审核年月 V_SHNY := SUBSTR(PI_JXRQ, 1, 6); V_ZHZT_ZC := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZC‘); --账户状态_正常 V_ZHZT_ZX := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZX‘); PO_FHZ := ‘1‘; FOR V_YLGRZH IN C_YLGRZH LOOP --生成养老年度帐户 YLNDZH_NDZH(V_YLGRZH.AAC001, PI_AAE140, PI_JXRQ, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END LOOP; --初始化 --因为每次帐户分配都已经更改了累计本金, --所以在作年度处理时,不需要处理累计本金;但处理累计利息 UPDATE SIC81 SET CAC046 = NVL(CAC046, 0) + NVL(AAE262, 0), AAE256 = NVL(AAE256, 0) + NVL(AAE263, 0), CAC047 = NVL(CAC047, 0) + NVL(AAE264, 0), AAE257 = NVL(AAE257, 0) + NVL(AAE265, 0), AAE262 = 0, AAE263 = 0, AAE264 = 0, AAE265 = 0 WHERE BAE001 = PI_BAE001 AND AAE140 = PI_AAE140 AND CAE246 != V_ZHZT_ZX; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ylgrzh_zhndcl_99‘; PO_MSG := ‘ylgrzh_zhndcl_养老个人帐户帐户年度处理时出现系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YLGRZH_ZHNDCL; --账户管理_账户建立日期同步 PROCEDURE ZHGL_ZHJLRQ_TB(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_AAC049 IN NUMBER, --个人参保年月 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_PARAMS VARCHAR2(2000); --传入参数串 V_PROCNAME VARCHAR2(50) := C_PKG_NAME || ‘zy_yilycxdj_dd‘; -- 过程名 V_AAC049 AC02.AAC049%TYPE; BEGIN V_PARAMS := ‘,入参为pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_aac049=‘ || PI_AAC049; IF SUBSTR(PI_AAE140, 1, 1) = ‘1‘ THEN V_AAC049 := SUBSTR(PI_AAC049, 1, 6); --企业养老其建账日期不能早于1994年7月 IF PI_AAE140 = PKG_FUN.F_GET_DICT(‘AAE140‘, ‘QYYL‘) THEN IF V_AAC049 < 199407 THEN V_AAC049 := 199407; END IF; --地方养老其建账日期不能早于2006年7月 /*ELSIF pi_aae140 = pkg_fun.f_get_dict(‘AAE140‘,‘DFYL‘) THEN IF v_AAC049 < 200607 THEN v_AAC049 :=200607; END IF;*/ --机关养老其建账日期不能早于1995年7月 ELSIF PI_AAE140 = PKG_FUN.F_GET_DICT(‘AAE140‘, ‘JGYL‘) THEN IF V_AAC049 < 199507 THEN V_AAC049 := 199507; END IF; /*ELSIF pi_aae140 =pkg_fun.f_get_dict(‘AAE140‘,‘NMYL‘) THEN IF v_AAC049 < 200101 THEN v_AAC049 :=200101; END IF; ELSIF pi_aae140 =pkg_fun.f_get_dict(‘AAE140‘,‘NCYL‘) THEN IF v_AAC049 < 200607 THEN v_AAC049 :=200607; END IF;*/ END IF; UPDATE SIC81 SET AAE206 = TO_NUMBER(SUBSTR(V_AAC049, 1, 6) || ‘01‘) WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; ELSE NULL; END IF; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘ZHGL_ZHJLRQ_TB_99‘; -- 请查看详细出错信息 PO_MSG := ‘同步帐户建立日期时出现系统错误,pi_aac001=‘ || PI_AAC001 || ‘请确认个人参保年月,‘ || PI_AAC049 || ‘险种类型‘ || PKG_FUN.F_GET_CSMC(‘AAE140‘, PI_AAE140) || ‘是否正确,系统错误信息:‘ || SQLERRM; END ZHGL_ZHJLRQ_TB; --养老年度帐户.年度帐户 PROCEDURE YLNDZH_NDZH(PI_AAC001 IN NUMBER, --个人顺序号 PI_AAE140 IN VARCHAR2, --险种类型 PI_JXRQ IN NUMBER, --计息日期 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS /*-- 变量声明 ----------------------------------------------------------*/ V_AAB001 AB01.AAB001%TYPE; --单位顺序号 V_BAE001 AC01.BAE001%TYPE; --系统机构代码 V_ND NUMBER; --年度 V_JXLL NUMBER; --记息利率 V_YLL NUMBER; --月利率 V_JFJS NUMBER; --缴费基数 V_SJJFGZ NUMBER; --实际缴费工资 V_QFYS NUMBER; --欠费月数 --养老个人账户 CURSOR C_YLGRZH IS SELECT * FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; BEGIN --查询单位顺序号和系统机构代码 BEGIN SELECT BAE001, AAB001 INTO V_BAE001, V_AAB001 FROM AC01 WHERE AAC001 = PI_AAC001; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘PKG_ZHGL_10‘; PO_MSG := ‘个人基本资料不存在!‘; END; --以下ylgrzh_sc过程在dgsbsj下没有进行处理,详细见原pkg_zhgl_b.sql --现针对ylgrzh_sc(22入参)调用现有ylgrzh_sc(4入参) --确定年度 --pkg_zscs.ndsz_qdnd( v_xtjgdm, pi_jxrq, v_nd, po_fhz, po_msg); --IF po_fhz != ‘1‘ THEN -- RETURN; --END IF; --确定利率 --pkg_zscs.jzll_qdll( v_xtjgdm, pi_jxrq, v_jxll, v_yll, po_fhz, po_msg); --IF po_fhz != ‘1‘ THEN -- RETURN; --END IF; --确定缴费基数 --pkg_grbg.grcbzl_qdjfjs( pi_grsxh, pi_xzlx, v_jfjs, po_fhz, po_msg); --IF po_fhz != ‘1‘ THEN -- RETURN; --END IF; --确定实际缴费工资 --pkg_gzsb.grgz_gzyjs( pi_grsxh, SUBSTR(pi_jxrq,1,6), -- v_sjjfgz, po_fhz, po_msg ); --IF po_fhz != ‘1‘ THEN -- RETURN; --END IF; --确定欠费月数 --SELECT COUNT(*) -- INTO v_qfys -- FROM ys_gryj -- WHERE grsxh = pi_grsxh -- AND xzlx = pi_xzlx -- AND yjlx IN (pkg_con.yjlx_yhd, pkg_con.yjlx_glbj) -- AND (dwjfbz IN ( pkg_con.dwjfbz_qj, pkg_con.dwjfbz_hj ) ); --生成养老年度帐户 FOR V_YLGRZH IN C_YLGRZH LOOP --如果没有养老个人账户则建立,否则不处理。 YLGRZH_SC(PI_AAC001, PI_AAE140, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END LOOP; --返回 PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL_90‘; PO_MSG := ‘养老年度帐户年度帐户时出现系统错误,系统错误信息:‘ || SQLERRM || ‘!‘; END YLNDZH_NDZH; --医保个人账户暂时未设计完。 /*PROCEDURE ybgrzh_zhndcl( pi_bae001 IN VARCHAR2, pi_jxrq IN NUMBER, pi_jbr IN NUMBER, po_fhz OUT VARCHAR2, po_msg OUT VARCHAR2 ) IS /*-- 变量声明 ----------------------------------------------------------*/ /* v_jbrq DATE; v_shny NUMBER; v_nll NUMBER; v_yfll NUMBER; v_zhjxlx s_xzsz.zhjxlx%TYPE; V_ZHZT_ZC SKC81.CAE246%TYPE; V_ZHZT_ZX SKC81.CAE246%TYPE; V_XZLX_JBYIL SKC82.AAE140%TYPE; BEGIN V_ZHZT_ZC := pkg_fun.f_get_dict(‘CAE246‘,‘ZC‘);--账户状态_正常 V_ZHZT_ZX := pkg_fun.f_get_dict(‘CAE246‘,‘ZX‘); V_XZLX_JBYIL:= pkg_fun.f_get_dict(‘AAE140‘,‘JBYIL‘); -- 确定帐户记息类型--医保个人账户暂时未设计完。 pkg_zscs.xzsz_qdxzcs( pi_bae001, V_XZLX_JBYIL, ‘zhjxlx‘, v_zhjxlx, po_fhz, po_msg ); IF po_fhz != ‘1‘ THEN RETURN; END IF; IF v_zhjxlx = pkg_con.zhjxlx_yhhq THEN -- a:活期记息 -- 判断输入参数(日期型:YYYYMMDD)的合法性 BEGIN IF LENGTH(pi_ksrq) = 6 THEN SELECT TO_DATE(pi_jxrq,‘YYYYMM‘) INTO v_jbrq FROM dual; ELSIF LENGTH(pi_ksrq) = 8 THEN SELECT TO_DATE(pi_jxrq,‘YYYYMMDD‘) INTO v_jbrq FROM dual; ELSE po_fhz := ‘PKG_zhgl.ybgrzh_zhndcl_01‘; po_msg := ‘传入日期:‘||pi_jxrq||‘日期参数的长度不合法!‘; RETURN; END IF; EXCEPTION WHEN OTHERS THEN po_fhz := ‘PKG_zhgl.ybgrzh_zhndcl_05‘; po_msg := ‘传入日期:‘||pi_jxrq||‘时数值日期转换时出错,出错信息为:‘||sqlerrm||‘!‘; END; v_shny := SUBSTR(pi_jxrq,1,6); -- 生成帐户配置明细 INSERT INTO SKC82 ( bae001, aab001, aac001, aae140, CAC044, CAC045, CAC037, CAE128, AAE011, CAE169, CAE170, CAE171) SELECT a.bae001, a.aab001, a.aac001, V_XZLX_JBYIL, a.CAC078, 0, a.CAC078, v_jbrq, AAE011, NULL, NULL, NULL, NULL--pkg_con.zhhrbpzt_yhr FROM SKC81 a, AAB001 b, AAC001 c WHERE b.bae001 = pi_bae001 AND a.bae001 = pi_bae001 AND a.bae001 = b.bae001 AND b.aab001 = a.aab001 AND c.aac001 = a.aac001 AND a.CAE246 IN (V_ZHZT_ZC, pkg_con.zhzt_fs)--东莞用到账户状态封锁的,考虑是否需要添加 AND a.CAC078 > 0; -- 修改医保个人帐户 UPDATE SKC81 SET AAE240 = NVL(AAE240,0) + NVL(CAC078,0) WHERE BAE001 = pi_bae001 AND CAE246 IN (V_ZHZT_ZC, pkg_con.zhzt_fs)--东莞用到账户状态封锁的,考虑是否需要添加 AND CAC078 > 0; UPDATE SKC81 SET AAE252 = NVL(AAE240,0),--上年账户金额=医保账户余额 CAC078 = 0, CAC079 = 0, AAE262 = 0, AAE264 = 0, CAC080 = 0 WHERE bae001 = pi_bae001 AND CAE246 IN (V_ZHZT_ZC, pkg_con.zhzt_fs);--东莞用到账户状态封锁的,考虑是否需要添加 -- 确定记帐利率 pkg_zhgl.jzll_qdll( pi_bae001, pi_jxrq, v_nll, v_yfll, po_fhz, po_msg); IF po_fhz != ‘1‘ THEN RETURN; END IF; UPDATE SIC81 SET CAC078 = NVL(AAE240,0) * v_nll WHERE bae001 = pi_bae001 AND cae246 IN (V_ZHZT_ZC, pkg_con.zhzt_fs) AND AAE240 > 0; ELSE -- 银行记息:修改医保个人帐户 UPDATE SIC81 SET AAE252 = NVL(AAE240,0), AAE262 = 0, AAE264 = 0, CAC080 = 0 WHERE bae001 = pi_bae001 AND zhzt IN (V_ZHZT_ZC, pkg_con.zhzt_fs); END IF; po_fhz := ‘1‘; EXCEPTION WHEN NO_DATA_FOUND THEN RETURN; WHEN OTHERS THEN po_fhz := ‘PKG_ZHGL_99‘; po_msg := ‘医保帐户年度初始化时出现系统错误,系统错误信息:‘||sqlerrm||‘!‘; END ybgrzh_zhndcl; --医保账户变更明细生成 PROCEDURE Ybzhbgmx_sc( pi_sKc83 IN SIC83%ROWTYPE, --医保保险变更明细行记录 po_fhz OUT VARCHAR2, --返回值 po_msg OUT VARCHAR2 --返回消息 ) IS BEGIN po_fhz := ‘1‘; --调用序列发生器SEQ_BXGX_CAE156生成帐户变更顺序号,并赋值给v_zhbgmx v_skc83 := pi_skc83; SELECT SEQ_BXGX_CAE156.nextval INTO v_skc83.cae156 FROM DUAL; --入参的人员ID是否大于0 IF pi_skc83.aac001 >0 THEN --调用医保帐户金额同步方法(ybgrzh_zhyetb)同步帐户金额 ybgrzh_zhyetb(); IF po_fhz != ‘1‘ THEN RETURN; END IF; --查询帐户变更明细本人本险种最后变动记录的累计金额,并累加本次变动金额赋值给v_zhbgmx的累计部分 --将v_zhbgmx插入到医保个人帐户变更明细表(SKC83) END IF; END Ybzhbgmx_sc; PROCEDURE ybgrzh_zhyetb( pi_aac001 IN NUMBER, --人员ID pi_aae140 IN VARCHAR2 , --险种类型 pi_aae341 IN VARCHAR2, --筹资项目 pi_bngrjn IN NUMBER, --本年个人缴纳 pi_bndwhr IN NUMBER, --本年单位划入 pi_bnjnlx IN NUMBER, --本年缴纳利息 pi_bnhrlx IN NUMBER, --本年划入利息 pi_dwjsje IN NUMBER, --单位减少金额 pi_grjsje IN NUMBER, --个人减少金额 po_fhz OUT VARCHAR2, --返回值 po_msg OUT VARCHAR2 --返回消息 ) IS v_cae246 SIC81.cae246%TYPE; V_ZHZT_ZX SIC81.CAE246%TYPE;--综合参数_账户状态_注销 V_CZXM_CANL SIC81.AAE341%TYPE; V_CZXM_ZCJF SIC81.AAE341%TYPE; V_CZXM_ZHONGYANG SIC81.AAE341%TYPE; V_CZXM_MZ SIC81.AAE341%TYPE; V_CZXM_SHENG SIC81.AAE341%TYPE; V_CZXM_SHI SIC81.AAE341%TYPE; V_CZXM_ZCZ SIC81.AAE341%TYPE; V_CZXM_XIAN SIC81.AAE341%TYPE; V_CZXM_ZICHOU SIC81.AAE341%TYPE; BEGIN V_ZHZT_ZX := pkg_fun.f_get_dict(‘CAE246‘,‘ZX‘);--获取账户状态_注销 V_CZXM_CANL := pkg_fun.f_get_dict(‘AAE341‘,‘CANL‘); --残联 V_CZXM_ZCJF := pkg_fun.f_get_dict(‘AAE341‘,‘ZCJF‘); --正常缴费 V_CZXM_ZHONGYANG := pkg_fun.f_get_dict(‘AAE341‘,‘ZHONGYANG‘); --中央财政 V_CZXM_MZ := pkg_fun.f_get_dict(‘AAE341‘,‘MZ‘); --民政 V_CZXM_SHENG := pkg_fun.f_get_dict(‘AAE341‘,‘SHENG‘); --省财政 V_CZXM_SHI := pkg_fun.f_get_dict(‘AAE341‘,‘SHI‘); --市财政 V_CZXM_ZCZ := pkg_fun.f_get_dict(‘AAE341‘,‘ZCZ‘); --镇财政 V_CZXM_XIAN := pkg_fun.f_get_dict(‘AAE341‘,‘XIAN‘); --县财政 V_CZXM_ZICHOU := pkg_fun.f_get_dict(‘AAE341‘,‘ZICHOU‘); --自筹 po_fhz := ‘1‘; BEGIN SELECT cae246 INTO v_cae246 FROM skc81 WHERE AAC001 = pi_aac001 AND AAE140 = pi_aae140 ; EXCEPTION WHEN NO_DATA_FOUND THEN po_fhz := ‘PKG_ZHGL.ybgrzh_zhyetb_01‘; po_msg := ‘个人顺序号为:‘||pi_aac001||‘的养老个人账户不存在,不能同步养老个人帐户,请核实‘; RETURN; WHEN OTHERS THEN po_fhz := ‘PKG_ZHGL.ybgrzh_zhyetb_02‘; -- 请查看详细出错信息 po_msg := ‘调用"PKG_ZHGL.ybgrzh_zhyetb"时系统错误,传入参数为:‘||‘pi_aac001:‘||pi_aac001||‘,pi_aae140:‘||pi_aae140||‘;系统错误信息:‘||sqlerrm||‘!‘; END; IF v_cae246 = V_ZHZT_ZX THEN po_fhz := ‘PKG_ZHGL.ybgrzh_zhyetb_03‘; po_msg := ‘个人顺序号为:‘||pi_aac001||‘,险种类型为:‘||pi_aae140||‘,其养老账户状态为注销,不能同步养老个人帐户,请核实‘; RETURN; END IF; --待补充 EXCEPTION WHEN OTHERS THEN po_fhz := ‘PKG_ZHGL.ybgrzh_zhyetb_99‘; -- 请查看详细出错信息 po_msg := ‘调用"PKG_ZHGL.ybgrzh_zhyetb"时系统错误,传入参数为:‘||‘pi_aac001:‘||pi_aac001||‘,pi_aae140:‘||pi_aae140||‘pi_aae341:‘||pi_aae341||‘;系统错误信息:‘||sqlerrm||‘!‘; END ybgrzh_zhyetb;*/ /* --养老个人账户.年度计息 PROCEDURE ylgrzh_grzhndjx ( pi_aac001 IN NUMBER, --人员ID pi_aae140 IN VARCHAR2, --险种类型 pi_aae030 IN NUMBER, --开始日期 pi_aae031 IN NUMBER, --终止日期 pi_nll IN NUMBER, --年利率 pi_jbr IN NUMBER, --经办人 po_fhz OUT VARCHAR2, po_msg OUT VARCHAR2 ) IS v_procname VARCHAR2(50) := c_pkg_name || ‘ylgrzh_grzhndjx‘; v_paramsc VARCHAR2(2000); BEGIN po_fhz := ‘1‘; EXCEPTION WHEN OTHERS THEN po_fhz := v_procname || ‘_999‘; po_msg := pkg_fun.f_errmsg(v_procname, SQLCODE, SQLERRM, v_paramsc); RETURN; END ylgrzh_grzhndjx; */ --养老个人账户.重算 PROCEDURE YLGRZH_CS(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_JSNY IN NUMBER, --计算年月 PI_JBR IN NUMBER, --经办人 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS V_PROCNAME VARCHAR2(50) := C_PKG_NAME || ‘ylgrzh_cs‘; V_PARAMSC VARCHAR2(2000); CURSOR C_SZMX IS SELECT CAE176, --帐户变动顺序号 BAE001, --a机构 AAB001, --组织ID@组织编号:组织唯一标识,系统生成。 AAC001, --人员ID CAE177, --收支方式@对应关系的缴费方式:自行缴费,下月台帐,对应待遇的待遇发放方式:银行正常划拨,个人帐户划拨,银行代发,农养老现金支付,异地商发其他银行划拨,农信社正常划拨,异地广发,异地信汇,异地邮汇本地信汇,送款上门,现金支付,单位银行信汇 CAE178, --收支标志@收入,支出 AAE341, --筹资项目@区分各级财务补贴、民政、残联等 CAE230, --帐户变动类型@地税到账,按人数征收补录,历史维护,人员合并,收入退款,企业转机关,机关转企业,企业转农保,农保转企业,农保转机关,机关转农保,市外转入到账,市外转入转医疗,市外转入转机关,市外转入转失业,市外转入转视同,市外转入转地方养老,市外转入转个人账户,转出市外,农保到账,待遇支付,待遇支付退回,年度计息,年中计息,财务调账财务调账 CAE231, --业务关键字段@缴费顺序号、待遇变更顺序号等 CAE232, --业务关键字段值@缴费顺序号、待遇变更顺序号等对应的值 AAE140, --险种类型 SZBZ * NVL(AAC123, 0) * SFBN AAC123_BN, --个人缴费金额 SZBZ * NVL(AAC124, 0) * SFBN AAC124_BN, --个人缴费利息 SZBZ * NVL(AAC125, 0) * SFBN AAC125_BN, --划入帐户金额 SZBZ * NVL(AAC126, 0) * SFBN AAC126_BN, --划入帐户利息 SZBZ * NVL(AAC123, 0) * (1 - SFBN) AAC123_LN, --个人缴费金额 SZBZ * NVL(AAC124, 0) * (1 - SFBN) AAC124_LN, --个人缴费利息 SZBZ * NVL(AAC125, 0) * (1 - SFBN) AAC125_LN, --划入帐户金额 SZBZ * NVL(AAC126, 0) * (1 - SFBN) AAC126_LN, --划入帐户利息 CAE124, --最后计息日期 CAA034, --利息计算标志@计息,不计息 CAE233, --帐户写入时间 CAE234, --帐户计息时间 CAC074, --累计个人缴费 CAC075, --累计单位划入帐户 CAC076, --累计个人缴费利息 CAC077, --累计单位缴费利息 AAE013, --备注 CAE682, --数据类型 CAE683, --财务确认时间 CAE684, --上年度累计利息*/ AAA031 --利率 FROM (SELECT A.*, DECODE(CAE178, C_CAE178_SR, 1, 0) SZBZ, DECODE(SUBSTR(CAE233, 1, 4), SUBSTR(201112, 1, 4), 1, 0) SFBN FROM SIC83 A WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140); V_SIC81 SIC81%ROWTYPE; --帐户行变量信息 V_SHNY_DY NUMBER; --审核年月当月 V_RYJBZL PKG_PUB.REC_RYJBZL; --人员资料变量 V_SIGN NUMBER; BEGIN V_PARAMSC := ‘入参为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140; --获取人员基本资料信息 PKG_PUB.RYJBZLCX(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; --获取当前审核年月下月 PKG_PUB.GETSHNYDY(V_RYJBZL.BAE001, V_SHNY_DY, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; IF PI_JSNY >= V_SHNY_DY THEN PO_FHZ := V_PROCNAME || ‘_010‘; PO_MSG := ‘传入的计算日期不能大于‘ || V_SHNY_DY || ‘.请核对.‘; RETURN; END IF; BEGIN SELECT * INTO V_SIC81 FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; V_SIC81.AAE262 := 0; -- NUMBER(16,2) Y 本年单位划入 V_SIC81.AAE264 := 0; -- NUMBER(16,2) Y 本年个人缴纳 V_SIC81.AAE263 := 0; -- NUMBER(16,2) Y 本年划入利息 V_SIC81.AAE265 := 0; -- NUMBER(16,2) Y 本年缴纳利息 V_SIC81.AAE253 := 0; -- NUMBER(16,2) Y 历年单位划入 V_SIC81.AAE254 := 0; -- NUMBER(16,2) Y 历年个人缴纳 V_SIC81.AAE256 := 0; -- NUMBER(16,2) Y 历年划入利息 V_SIC81.AAE257 := 0; -- NUMBER(16,2) Y 历年缴纳利息 V_SIC81.CAC046 := 0; -- NUMBER(16,2) Y 单位划入余额 V_SIC81.CAC047 := 0; -- NUMBER(16,2) Y 个人缴纳余额 --v_sic81.aae206 := 0; -- NUMBER(8) Y 帐户建立日期 --v_sic81.cac048 := 0; -- NUMBER(16,2) Y 38号文实施前个人缴纳余额 --v_sic81.cac052 := 0; -- NUMBER(16,2) Y 38号文实施前单位划入余额 --v_sic81.cac053 := 0; -- NUMBER(16,2) Y 农保转入金额 V_SIC81.CAC054 := 0; -- NUMBER(16,2) Y 本年省财政划入 V_SIC81.CAC055 := 0; -- NUMBER(16,2) Y 本年市财政划入 V_SIC81.CAC056 := 0; -- NUMBER(16,2) Y 本年区财政划入 V_SIC81.CAC057 := 0; -- NUMBER(16,2) Y 本年其它财政划入 V_SIC81.CAC058 := 0; -- NUMBER(16,2) Y 历年省财政划入 V_SIC81.CAC059 := 0; -- NUMBER(16,2) Y 历年市财政划入 V_SIC81.CAC060 := 0; -- NUMBER(16,2) Y 历年区财政划入 V_SIC81.CAC061 := 0; -- NUMBER(16,2) Y 历年其它财政划入 V_SIC81.CAC062 := 0; -- NUMBER(16,2) Y 本年省财政划入利息 V_SIC81.CAC063 := 0; -- NUMBER(16,2) Y 本年市财政划入利息 V_SIC81.CAC064 := 0; -- NUMBER(16,2) Y 本年区财政划入利息 V_SIC81.CAC065 := 0; -- NUMBER(16,2) Y 本年其它财政划入利息 V_SIC81.CAC066 := 0; -- NUMBER(16,2) Y 历年省财政划入利息 V_SIC81.CAC067 := 0; -- NUMBER(16,2) Y 历年市财政划入利息 V_SIC81.CAC068 := 0; -- NUMBER(16,2) Y 历年区财政划入利息 V_SIC81.CAC069 := 0; -- NUMBER(16,2) Y 历年其它财政划入利息 V_SIC81.CAC070 := 0; -- NUMBER(16,2) Y 省财政划入余额 V_SIC81.CAC071 := 0; -- NUMBER(16,2) Y 市财政划入余额 V_SIC81.CAC072 := 0; -- NUMBER(16,2) Y 区财政划入余额 V_SIC81.CAC073 := 0; -- NUMBER(16,2) Y 其它财政划入余额 EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := V_PROCNAME || ‘_020‘; PO_MSG := ‘参保人的养老账户不存在.请核实.入参为:‘ || V_PARAMSC; RETURN; WHEN TOO_MANY_ROWS THEN PO_FHZ := V_PROCNAME || ‘_030‘; PO_MSG := ‘参保人的养老账户存在多个.请核实.入参为:‘ || V_PARAMSC; RETURN; END; FOR V_MX IN C_SZMX LOOP IF V_MX.AAE341 IN (C_AAE341_ZCJF, C_AAE341_ZICHOU) THEN --正常缴费,自筹 V_SIC81.AAE262 := NVL(V_SIC81.AAE262, 0) + V_MX.AAC125_BN; --本年单位划入 V_SIC81.AAE264 := NVL(V_SIC81.AAE264, 0) + V_MX.AAC123_BN; --本年个人缴纳 V_SIC81.AAE263 := NVL(V_SIC81.AAE263, 0) + V_MX.AAC126_BN; --本年划入利息 V_SIC81.AAE265 := NVL(V_SIC81.AAE265, 0) + V_MX.AAC124_BN; --本年缴纳利息 V_SIC81.AAE253 := NVL(V_SIC81.AAE253, 0) + V_MX.AAC125_LN; --历年单位划入 V_SIC81.AAE254 := NVL(V_SIC81.AAE254, 0) + V_MX.AAC123_LN; --历年个人缴纳 V_SIC81.AAE256 := NVL(V_SIC81.AAE256, 0) + V_MX.AAC126_LN; --历年划入利息 V_SIC81.AAE257 := NVL(V_SIC81.AAE257, 0) + V_MX.AAC124_LN; --历年缴纳利息 ELSIF V_MX.AAE341 = C_AAE341_SHENG THEN --省财政 V_SIC81.CAC054 := NVL(V_SIC81.CAC054, 0) + V_MX.AAC125_BN; --本年省财政划入 V_SIC81.CAC058 := NVL(V_SIC81.CAC058, 0) + V_MX.AAC125_LN; --历年省财政划入 V_SIC81.CAC062 := NVL(V_SIC81.CAC062, 0) + V_MX.AAC126_BN; --本年省财政划入利息 V_SIC81.CAC066 := NVL(V_SIC81.CAC066, 0) + V_MX.AAC126_LN; --历年省财政划入利息 ELSIF V_MX.AAE341 IN (C_AAE341_SHI, C_AAE341_FPCSFD) THEN --市财政,扶贫村市分担 V_SIC81.CAC055 := NVL(V_SIC81.CAC055, 0) + V_MX.AAC125_BN; --本年市财政划入 V_SIC81.CAC059 := NVL(V_SIC81.CAC059, 0) + V_MX.AAC125_LN; --历年市财政划入 V_SIC81.CAC063 := NVL(V_SIC81.CAC063, 0) + V_MX.AAC126_BN; --本年市财政划入利息 V_SIC81.CAC067 := NVL(V_SIC81.CAC067, 0) + V_MX.AAC126_LN; --历年市财政划入利息 ELSIF V_MX.AAE341 IN (C_AAE341_ZCZ, C_AAE341_XIAN, C_AAE341_FPCZFD) THEN --镇财政,县财政,扶贫村镇分担 V_SIC81.CAC056 := NVL(V_SIC81.CAC056, 0) + V_MX.AAC125_BN; --本年区财政划入 V_SIC81.CAC060 := NVL(V_SIC81.CAC060, 0) + V_MX.AAC125_LN; --历年区财政划入 V_SIC81.CAC064 := NVL(V_SIC81.CAC064, 0) + V_MX.AAC126_BN; --本年区财政划入利息 V_SIC81.CAC068 := NVL(V_SIC81.CAC068, 0) + V_MX.AAC126_LN; --历年区财政划入利息 ELSIF V_MX.AAE341 IN (C_AAE341_MZ, C_AAE341_CANL) THEN --民政,残联 V_SIC81.CAC057 := NVL(V_SIC81.CAC057, 0) + V_MX.AAC125_BN; --本年其它财政划入 V_SIC81.CAC061 := NVL(V_SIC81.CAC061, 0) + V_MX.AAC125_LN; --历年其它财政划入 V_SIC81.CAC065 := NVL(V_SIC81.CAC065, 0) + V_MX.AAC126_BN; --本年其它财政划入利息 V_SIC81.CAC069 := NVL(V_SIC81.CAC069, 0) + V_MX.AAC126_LN; --历年其它财政划入利息 ELSE PO_FHZ := V_PROCNAME || ‘_040‘; PO_MSG := ‘筹资项目为‘ || V_MX.AAE341 || ‘.不正确.请核实.入参为:‘ || V_PARAMSC; RETURN; END IF; END LOOP; --更新余额字段 V_SIC81.CAC046 := NVL(V_SIC81.AAE262, 0) + NVL(V_SIC81.AAE263, 0) + NVL(V_SIC81.AAE253, 0) + NVL(V_SIC81.AAE256, 0); --单位划入余额=本年单位划入+本年划入利息+历年单位划入+历年划入利息 V_SIC81.CAC047 := NVL(V_SIC81.AAE264, 0) + NVL(V_SIC81.AAE265, 0) + NVL(V_SIC81.AAE254, 0) + NVL(V_SIC81.AAE257, 0); --个人缴纳余额=本年个人缴纳+本年缴纳利息+历年个人缴纳+历年缴纳利息 V_SIC81.CAC070 := NVL(V_SIC81.CAC054, 0) + NVL(V_SIC81.CAC058, 0) + NVL(V_SIC81.CAC062, 0) + NVL(V_SIC81.CAC066, 0); --省财政划入余额=本年省财政划入+历年省财政划入+本年省财政划入利息+历年省财政划入利息 V_SIC81.CAC071 := NVL(V_SIC81.CAC055, 0) + NVL(V_SIC81.CAC059, 0) + NVL(V_SIC81.CAC063, 0) + NVL(V_SIC81.CAC067, 0); --市财政划入余额=本年市财政划入+历年市财政划入+本年市财政划入利息+历年市财政划入利息 V_SIC81.CAC072 := NVL(V_SIC81.CAC056, 0) + NVL(V_SIC81.CAC060, 0) + NVL(V_SIC81.CAC064, 0) + NVL(V_SIC81.CAC068, 0); --区财政划入余额=本年区财政划入+历年区财政划入+本年区财政划入利息+历年区财政划入利息 V_SIC81.CAC073 := NVL(V_SIC81.CAC057, 0) + NVL(V_SIC81.CAC061, 0) + NVL(V_SIC81.CAC065, 0) + NVL(V_SIC81.CAC069, 0); --其它财政划入余额=本年其它财政划入+历年其它财政划入+本年其它财政划入利息+历年其它财政划入利息 UPDATE SIC81 SET AAE262 = NVL(V_SIC81.AAE262, 0), -- 本年单位划入 AAE264 = NVL(V_SIC81.AAE264, 0), -- 本年个人缴纳 AAE263 = NVL(V_SIC81.AAE263, 0), -- 本年划入利息 AAE265 = NVL(V_SIC81.AAE265, 0), -- 本年缴纳利息 AAE253 = NVL(V_SIC81.AAE253, 0), -- 历年单位划入 AAE254 = NVL(V_SIC81.AAE254, 0), -- 历年个人缴纳 AAE256 = NVL(V_SIC81.AAE256, 0), -- 历年划入利息 AAE257 = NVL(V_SIC81.AAE257, 0), -- 历年缴纳利息 CAC046 = NVL(V_SIC81.CAC046, 0), -- 单位划入余额 CAC047 = NVL(V_SIC81.CAC047, 0), -- 个人缴纳余额 CAC054 = NVL(V_SIC81.CAC054, 0), -- 本年省财政划入 CAC055 = NVL(V_SIC81.CAC055, 0), -- 本年市财政划入 CAC056 = NVL(V_SIC81.CAC056, 0), -- 本年区财政划入 CAC057 = NVL(V_SIC81.CAC057, 0), -- 本年其它财政划入 CAC058 = NVL(V_SIC81.CAC058, 0), -- 历年省财政划入 CAC059 = NVL(V_SIC81.CAC059, 0), -- 历年市财政划入 CAC060 = NVL(V_SIC81.CAC060, 0), -- 历年区财政划入 CAC061 = NVL(V_SIC81.CAC061, 0), -- 历年其它财政划入 CAC062 = NVL(V_SIC81.CAC062, 0), -- 本年省财政划入利息 CAC063 = NVL(V_SIC81.CAC063, 0), -- 本年市财政划入利息 CAC064 = NVL(V_SIC81.CAC064, 0), -- 本年区财政划入利息 CAC065 = NVL(V_SIC81.CAC065, 0), -- 本年其它财政划入利息 CAC066 = NVL(V_SIC81.CAC066, 0), -- 历年省财政划入利息 CAC067 = NVL(V_SIC81.CAC067, 0), -- 历年市财政划入利息 CAC068 = NVL(V_SIC81.CAC068, 0), -- 历年区财政划入利息 CAC069 = NVL(V_SIC81.CAC069, 0), -- 历年其它财政划入利息 CAC070 = NVL(V_SIC81.CAC070, 0), -- 省财政划入余额 CAC071 = NVL(V_SIC81.CAC071, 0), -- 市财政划入余额 CAC072 = NVL(V_SIC81.CAC072, 0), -- 区财政划入余额 CAC073 = NVL(V_SIC81.CAC073, 0) -- 其它财政划入余额 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PARAMSC); RETURN; END YLGRZH_CS; --账户调整 PROCEDURE GRZH_TZ(PI_BAE001 IN VARCHAR2, -- 系统机构代码 PI_AAB001 IN NUMBER, -- 组织ID PI_AAC001 IN NUMBER, -- 人员ID PI_CAE794 IN VARCHAR2, -- 业务类型 PI_CAE795 IN VARCHAR2, -- 调出账户或基金类型 PI_CAE796 IN VARCHAR2, -- 调入账户或基金类型 PI_AAC123 IN NUMBER, -- 个人缴费金额 PI_AAC125 IN NUMBER, -- 划入账户金额 PI_AAC127 IN NUMBER, -- 划入统筹金额 PI_BAE007 IN VARCHAR2, -- 业务流水号 PO_FHZ OUT VARCHAR2, -- 返回值 PO_MSG OUT VARCHAR2 -- 返回信息 ) IS V_PARAMS VARCHAR2(2000); --传入参数串 V_PROCNAME VARCHAR2(50) := C_PKG_NAME || ‘grzh_tz‘; -- 过程名 V_CAZ541 NUMBER; V_AAE140 VARCHAR2(6); BEGIN --初始化返回值 PO_FHZ := ‘1‘; --初始化返回信息入参串 V_PARAMS := ‘,传入参数为:pi_bae001=‘ || PI_BAE001 || ‘,pi_aab001=‘ || PI_AAB001 || ‘,pi_aac001=‘ || PI_AAC001 || ‘,pi_CAE794=‘ || PI_CAE794 || ‘,pi_CAE795=‘ || PI_CAE795 || ‘,pi_CAE796=‘ || PI_CAE796 || ‘,pi_bae007=‘ || PI_BAE007; --生成调账顺序号 SELECT SEQ_BXGX_CAZ541.NEXTVAL INTO V_CAZ541 FROM DUAL; --生成账户调整记录 INSERT INTO ACA9 (BAE001, AAB001, AAC001, BAE007, CAZ541, CAE794, CAE795, CAE796, CAE797, CAE798, CAE799, CAE800, CAE683, AAE013, AAC123, AAC125, AAC127) VALUES (PI_BAE001, PI_AAB001, PI_AAC001, PI_BAE007, V_CAZ541, PI_CAE794, PI_CAE795, PI_CAE796, NVL(PI_AAC123, 0) + NVL(PI_AAC125, 0) + NVL(PI_AAC125, 0), NULL, NULL, NULL, NULL, NULL, PI_AAC123, PI_AAC125, PI_AAC127); --根据调出账户类别确定调出险种类型 --生成一条调出账户的账户支出明细 PKG_ZHGL.YLZHBGMX_QTYS(PI_AAB001, --组织ID PI_AAC001, --人员ID PI_BAE001, --系统机构代码 ‘CAZ541‘, --业务关键字段 V_CAZ541, --业务关键字段值 V_AAE140, --险种类型 C_AAE341_ZCJF, --筹资项目 PKG_FUN.F_GET_SYSDATE(8), --帐户写入时间 PI_AAC123, --个人缴费金额 PI_AAC125, --划入账户金额 PI_AAC127, --划入统筹金额 C_CAE230_KXZTZ, --账户变动类型 C_CAE178_ZC, --收支类型 ‘账户调整支出明细‘, --备注 PO_FHZ, --返回值 PO_MSG --返回消息 ); --生成一条调入账户的账户收入明细 PKG_ZHGL.YLZHBGMX_QTYS(PI_AAB001, --组织ID PI_AAC001, --人员ID PI_BAE001, --系统机构代码 ‘CAZ541‘, --业务关键字段 V_CAZ541, --业务关键字段值 V_AAE140, --险种类型 C_AAE341_ZCJF, --筹资项目 PKG_FUN.F_GET_SYSDATE(8), --帐户写入时间 PI_AAC123, --个人缴费金额 PI_AAC125, --划入账户金额 PI_AAC127, --划入统筹金额 C_CAE230_KXZTZ, --账户变动类型 C_CAE178_SR, --收支类型 ‘账户调整支出明细‘, --备注 PO_FHZ, --返回值 PO_MSG --返回消息 ); EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PARAMS); RETURN; END; --养老个人账户.年度结转 PROCEDURE YLGRZH_GRNDJZ(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_JZND IN VARCHAR2, --格式为YYYY PI_AAE011 IN VARCHAR2, --经办人(预留后面生成账户变动记录) PI_BZ IN VARCHAR2, --备注 PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回信息 ) IS V_SIC81 SIC81%ROWTYPE; V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_grndjz‘; V_PROCPARAMS VARCHAR2(3000); BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jznd=‘ || PI_JZND || ‘,pi_aae011=‘ || PI_AAE011 || ‘,pi_bz=‘ || PI_BZ; --获取养老个人账户 PKG_ZHGL.YLGRZH_CX(PI_AAC001, PI_AAE140, V_SIC81, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; IF V_SIC81.CAE246 = PKG_BXGX_CON.CAE246_ZX THEN PO_FHZ := V_PROCNAME || ‘_100‘; PO_MSG := ‘参保人账户已经注销,不允许做年度结转.‘ || V_PROCPARAMS; RETURN; END IF; /* 1.将本年度月积数额给值为上年度月积数额 2.以此时的账户余额*12作为本年度月积数额 3.将本年的本金记载字段更新至对应的历年本金部分 4.将本年的利息记载字段更新至对应的历年利息部分 */ --增加判断 /* 要增加一个判断,就是做年度结转时,要判断上年度是否做过年度结息 如果没有,还不给他结转 */ IF SUBSTR(NVL(V_SIC81.CAE124, 19000101), 1, 8) < (PI_JZND - 1) || ‘1231‘ THEN PO_FHZ := V_PROCNAME || ‘_200‘; PO_MSG := ‘此参保人上年度还未做过年度结息.请先做上年度(‘ || (PI_JZND - 1) || ‘)的年度结息,再做(‘ || PI_JZND || ‘)的年度结转.‘; RETURN; END IF; YLGRZH_JXQBF(V_SIC81, ‘3‘, ‘‘, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --此时已做过上年年度结息,上年积数额部分均为0 UPDATE SIC81 SET CIE585 = NVL(V_SIC81.CIE579, 0), --上年积数额_单位划入 CIE586 = NVL(V_SIC81.CIE580, 0), --上年积数额_个人缴纳 CIE587 = NVL(V_SIC81.CIE581, 0), --上年积数额_省财政划入 CIE588 = NVL(V_SIC81.CIE582, 0), --上年积数额_市财政划入 CIE589 = NVL(V_SIC81.CIE583, 0), --上年积数额_区财政划入 CIE590 = NVL(V_SIC81.CIE584, 0), --上年积数额_其它财政划入 CIE579 = NVL(V_SIC81.CAC046, 0) * 12, --本年积数额_单位划入 CAC046 单位划入余额 CIE580 = NVL(V_SIC81.CAC047, 0) * 12, --本年积数额_个人缴纳 CAC047 个人缴纳余额 CIE581 = NVL(V_SIC81.CAC070, 0) * 12, --本年积数额_省财政划入 CAC070 省财政划入余额 CIE582 = NVL(V_SIC81.CAC071, 0) * 12, --本年积数额_市财政划入 CAC071 市财政划入余额 CIE583 = NVL(V_SIC81.CAC072, 0) * 12, --本年积数额_区财政划入 CAC072 区财政划入余额 CIE584 = NVL(V_SIC81.CAC073, 0) * 12, --本年积数额_其它财政划入 CAC073 其它财政划入余额 AAE253 = NVL(AAE253, 0) + NVL(V_SIC81.AAE262, 0), --历年单位划入 AAE254 = NVL(AAE254, 0) + NVL(V_SIC81.AAE264, 0), --历年个人缴纳 CAC058 = NVL(CAC058, 0) + NVL(V_SIC81.CAC054, 0), --历年省财政划入 CAC059 = NVL(CAC059, 0) + NVL(V_SIC81.CAC055, 0), --历年市财政划入 CAC060 = NVL(CAC060, 0) + NVL(V_SIC81.CAC056, 0), --历年区财政划入 CAC061 = NVL(CAC061, 0) + NVL(V_SIC81.CAC057, 0), --历年其它财政划入 AAE256 = NVL(AAE256, 0) + NVL(V_SIC81.AAE263, 0), --历年划入利息 AAE257 = NVL(AAE257, 0) + NVL(V_SIC81.AAE265, 0), --历年缴纳利息 CAC066 = NVL(CAC066, 0) + NVL(V_SIC81.CAC062, 0), --历年省财政划入利息 CAC067 = NVL(CAC067, 0) + NVL(V_SIC81.CAC063, 0), --历年市财政划入利息 CAC068 = NVL(CAC068, 0) + NVL(V_SIC81.CAC064, 0), --历年区财政划入利息 CAC069 = NVL(CAC069, 0) + NVL(V_SIC81.CAC065, 0), --历年其它财政划入利息 AAE262 = 0, --本年单位划入 AAE264 = 0, --本年个人缴纳 CAC054 = 0, --本年省财政划入 CAC055 = 0, --本年市财政划入 CAC056 = 0, --本年区财政划入 CAC057 = 0, --本年其它财政划入 AAE263 = 0, --本年划入利息 AAE265 = 0, --本年缴纳利息 CAC062 = 0, --本年省财政划入利息 CAC063 = 0, --本年市财政划入利息 CAC064 = 0, --本年区财政划入利息 CAC065 = 0 --本年其它财政划入利息 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END; --养老个人账户.年度结息 PROCEDURE YLGRZH_GRNDJX(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_JXND IN VARCHAR2, --年度 PI_AAE011 IN VARCHAR2, --经办人(预留后面生成账户变动记录) PI_XXC IN VARCHAR2, --信息串(字段名1=值1||CHR(3)||字段名2=值2) PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回信息 ) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_grndjx‘; V_PROCPARAMS VARCHAR2(3000); V_SIC81 SIC81%ROWTYPE; V_ZHJXRQ VARCHAR2(8); V_SNLX TYPE_ZHJE; --上年利息(结构) V_BNLX TYPE_ZHJE; --本年利息(结构) V_JSE_BN TYPE_ZHJE; --本年积数额(结构) V_YLL_SN NUMBER; --上年月利率 V_YLL_BN NUMBER; --本年月利率 V_BZ VARCHAR2(100); --备注 /* 从目前情况看,国家每年3月左右才公布上一年度使用的月利率,因此上一年度的结息会推迟到新年度的3-4月左右 真正做年度结息时,已做过年度结转: 前置条件 不允许跨年度做年度结息。如某参保人的养老账户在20091231做了年度结息,而没有做20101231的年度结息,则现在不允许直接做20111231的年度结息。 计息步骤: 计算上年度的结转利息:养老账户中上年度积数额*上年度月利率=上年度的结转利息 本年度月积数额=本年度月积数额+上年度的结转利息*12 计算本年度的结转利息:本年度月积数额*本年利率 清空计算上年度月积额 账户余额:结息前的账户余额+上年度的结转利息 (此处利息累加至历年利息部分) */ BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxnd=‘ || PI_JXND || ‘,pi_aae011=‘ || PI_AAE011 || ‘,pi_xxc=‘ || PI_XXC; --获取养老个人账户 PKG_ZHGL.YLGRZH_CX(PI_AAC001, PI_AAE140, V_SIC81, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; IF V_SIC81.CAE246 = PKG_BXGX_CON.CAE246_ZX THEN PO_FHZ := V_PROCNAME || ‘_100‘; PO_MSG := ‘参保人账户已经注销,不允许做年度结息.‘ || V_PROCPARAMS; RETURN; END IF; --20120419 Jinqingyu 添加校验(如果账户余额为0,则不再计息;如果为负数,则抛出异常) IF NVL(V_SIC81.CAC046, 0) + NVL(V_SIC81.CAC047, 0) = 0 THEN PO_FHZ := ‘1‘; RETURN; END IF; /* IF NVL(v_sic81.CAC046,0)+NVL(v_sic81.CAC047,0)<0 then po_fhz := v_procname || ‘_310‘; po_msg := ‘参保人账户余额为负数.不允许计息.请检查数据.‘||v_procparams; RETURN; END IF; */ V_ZHJXRQ := SUBSTR(NVL(V_SIC81.CAE124, 19000101), 1, 8); IF PI_JXND - SUBSTR(V_ZHJXRQ, 1, 4) >= 2 THEN PO_FHZ := V_PROCNAME || ‘_200‘; PO_MSG := ‘参保人对应险种上年度(‘ || (PI_JXND - 1) || ‘)未做年度结息.不允许跨多个年度进行结息.‘; RETURN; END IF; IF V_ZHJXRQ > PI_JXND || ‘1231‘ THEN PO_FHZ := V_PROCNAME || ‘_250‘; PO_MSG := ‘参保人本年度已做过年度结息.不允许重复做年度结息.参保人在年度‘ || PI_JXND || ‘1231‘ || ‘有过结息记录.最后的结息日期为:‘ || V_ZHJXRQ; RETURN; END IF; --begin:计算上年度的结转利息 --1.获取上年度的利率 PKG_ZSCS.GETJZLL(V_SIC81.BAE001, --a机构 PI_AAE140, --险种类型 PKG_BXGX_CON.AAA030_JZNLL, --利率滞纳金类型@年利率,月利率,滞纳金利率 PI_JXND || ‘0101‘, --计息日期 V_YLL_SN, --a记账利率 PO_FHZ, --返回值 PO_MSG --返回信息 ); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; V_YLL_SN := V_YLL_SN / 12; --换算成月利率 --2.计算上年度的结转利息 V_SNLX.YLL := V_YLL_SN; V_SNLX.DWHR := V_YLL_SN * NVL(V_SIC81.CIE585, 0); --单位划入 V_SNLX.GRJN := V_YLL_SN * NVL(V_SIC81.CIE586, 0); --个人缴纳 V_SNLX.HR_SHENG := V_YLL_SN * NVL(V_SIC81.CIE587, 0); --省财政划入 V_SNLX.HR_SHI := V_YLL_SN * NVL(V_SIC81.CIE588, 0); --市财政划入 V_SNLX.HR_QU := V_YLL_SN * NVL(V_SIC81.CIE589, 0); --区财政划入 V_SNLX.HR_QTCZ := V_YLL_SN * NVL(V_SIC81.CIE590, 0); --其它财政划入 --end:计算上年度的结转利息 --begin:本年度月积数额 --本年度月积数额=本年度月积数额+上年度的结转利息*12 V_JSE_BN.DWHR := NVL(V_SIC81.CIE579, 0) + NVL(V_SNLX.DWHR, 0) * 12; --本年积数额_单位划入 V_JSE_BN.GRJN := NVL(V_SIC81.CIE580, 0) + NVL(V_SNLX.GRJN, 0) * 12; --本年积数额_个人缴纳 V_JSE_BN.HR_SHENG := NVL(V_SIC81.CIE581, 0) + NVL(V_SNLX.HR_SHENG, 0) * 12; --本年积数额_省财政划入 V_JSE_BN.HR_SHI := NVL(V_SIC81.CIE582, 0) + NVL(V_SNLX.HR_SHI, 0) * 12; --本年积数额_市财政划入 V_JSE_BN.HR_QU := NVL(V_SIC81.CIE583, 0) + NVL(V_SNLX.HR_QU, 0) * 12; --本年积数额_区财政划入 V_JSE_BN.HR_QTCZ := NVL(V_SIC81.CIE584, 0) + NVL(V_SNLX.HR_QTCZ, 0) * 12; --本年积数额_其它财政划入 --end:本年度月积数额 YLGRZH_JXQBF(V_SIC81, ‘1‘, ‘‘, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --更新账户各金额字段 UPDATE SIC81 SET CIE585 = 0, --上年积数额_单位划入 CIE586 = 0, --上年积数额_个人缴纳 CIE587 = 0, --上年积数额_省财政划入 CIE588 = 0, --上年积数额_市财政划入 CIE589 = 0, --上年积数额_区财政划入 CIE590 = 0, --上年积数额_其它财政划入 CIE579 = V_JSE_BN.DWHR, --本年积数额_单位划入 CIE580 = V_JSE_BN.GRJN, --本年积数额_个人缴纳 CIE581 = V_JSE_BN.HR_SHENG, --本年积数额_省财政划入 CIE582 = V_JSE_BN.HR_SHI, --本年积数额_市财政划入 CIE583 = V_JSE_BN.HR_QU, --本年积数额_区财政划入 CIE584 = V_JSE_BN.HR_QTCZ, --本年积数额_其它财政划入 CAE124 = PI_JXND || ‘1231‘ --pkg_fun.f_get_sysdate(14) WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; V_BZ := PKG_FUN.F_GET_VALUE(PI_XXC, ‘bz‘, CHR(3)); --TODO:调用账户收支明细事件,生成利息收入 --调用账户收支明细事件,生成利息收入 YLZHBGMX_LXSC(PI_AAC001, --人员ID PI_AAE140, --险种类型 V_SNLX, --利息(结构) ‘1‘, --计算类型(1为年度结息,2为年中结息) ‘bz=年度结息‘, --信息串(字段名1=值1||CHR(3)||字段名2=值2) PO_FHZ, --返回值 PO_MSG, --返回消息 PI_JXND); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END; --养老个人账户.年中结息 PROCEDURE YLGRZH_GRNZJX(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_JXRQ IN VARCHAR2, --计息日期 PI_AAE011 IN VARCHAR2, --经办人(预留后面生成账户变动记录) PI_XXC IN VARCHAR2, --信息串(字段名1=值1||CHR(3)||字段名2=值2) PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回信息 ) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_grnzjx‘; V_PROCPARAMS VARCHAR2(3000); V_SIC81 SIC81%ROWTYPE; V_ZHJXRQ VARCHAR2(14); V_SNLX TYPE_ZHJE; --上年利息(结构) V_BNLX TYPE_ZHJE; --本年利息(结构) V_JSE_BN TYPE_ZHJE; --本年积数额(结构) V_JSE_SY TYPE_ZHJE; --本年积数额_剩余(结构) V_YLL_SN NUMBER; --上年月利率 V_YLL_BN NUMBER; --本年月利率 V_SYYS NUMBER; V_BZ VARCHAR2(100); --备注 V_JXRQ DATE; BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxrq=‘ || PI_JXRQ || ‘,pi_aae011=‘ || PI_AAE011 || ‘,pi_xxc=‘ || PI_XXC; --对入参进行检测 BEGIN SELECT TO_DATE(PI_JXRQ, ‘yyyymmdd‘) INTO V_JXRQ FROM DUAL; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_100‘; PO_MSG := ‘传入的结息日期‘ || PI_JXRQ || ‘不是一个合法的日期(YYYYMMDD)‘ || V_PROCPARAMS; RETURN; END; --对入参进行检测 IF SUBSTRB(PI_JXRQ, 1, 4) != TO_CHAR(SYSDATE, ‘YYYY‘) THEN PO_FHZ := V_PROCNAME || ‘_200‘; PO_MSG := ‘传入的结息日期‘ || PI_JXRQ || ‘不是本年的日期.不允许做年中结息.请核对.‘ || V_PROCPARAMS; RETURN; END IF; --获取养老个人账户 PKG_ZHGL.YLGRZH_CX(PI_AAC001, PI_AAE140, V_SIC81, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; IF V_SIC81.CAE246 = PKG_BXGX_CON.CAE246_ZX THEN PO_FHZ := V_PROCNAME || ‘_300‘; PO_MSG := ‘参保人账户已经注销,不允许做年中结息.‘ || V_PROCPARAMS; RETURN; END IF; --20120419 Jinqingyu 添加校验(如果账户余额为0,则不再计息;如果为负数,则抛出异常) IF NVL(V_SIC81.CAC046, 0) + NVL(V_SIC81.CAC047, 0) = 0 THEN PO_FHZ := ‘1‘; RETURN; END IF; /* IF NVL(v_sic81.CAC046,0)+NVL(v_sic81.CAC047,0)<0 then po_fhz := v_procname || ‘_310‘; po_msg := ‘参保人账户余额为负数.不允许计息.请检查数据.‘||v_procparams; RETURN; END IF; */ V_ZHJXRQ := SUBSTR(NVL(V_SIC81.CAE124, 19000101), 1, 8); --20120518 金庆余修改:1.同一月份不允许多次结息 2.传入结算年月(含同月)已有结息记录的,直接返回 IF SUBSTR(V_ZHJXRQ, 1, 6) >= SUBSTRB(PI_JXRQ, 1, 6) THEN PO_FHZ := ‘1‘; RETURN; END IF; --v_bz := pkg_fun.f_get_value(pi_xxc, ‘bz‘, chr(3)); --校验一下,判断上年度是否有年度结息记录:如果没有,需要先调用上年的年度结息程序 IF SUBSTR(V_ZHJXRQ, 1, 8) < (SUBSTRB(PI_JXRQ, 1, 4) - 1) || ‘1231‘ THEN YLGRZH_GRNDJX(PI_AAC001, PI_AAE140, SUBSTRB(PI_JXRQ, 1, 4) - 1, PI_AAE011, PI_XXC, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; --20120210 Jinqingyu 重新获取账户信息(SIC81).否则后续使用的行变量v_sic81不是本程序调用年度结息后 PKG_ZHGL.YLGRZH_CX(PI_AAC001, PI_AAE140, V_SIC81, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; END IF; V_SYYS := 12 - SUBSTRB(PI_JXRQ, 5, 2); --1.获取上年度的利率 PKG_ZSCS.GETJZLL(V_SIC81.BAE001, --a机构 PI_AAE140, --险种类型 PKG_BXGX_CON.AAA030_JZNLL, --利率滞纳金类型@年利率,月利率,滞纳金利率 SUBSTRB(PI_JXRQ, 1, 4) || ‘0101‘, --计息日期 V_YLL_BN, --a记账利率 PO_FHZ, --返回值 PO_MSG --返回信息 ); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; V_YLL_BN := V_YLL_BN / 12; --换算成月利率 V_JSE_SY.DWHR := NVL(V_SIC81.CAC046, 0) * V_SYYS; --本年积数额_剩余_单位划入 V_JSE_SY.GRJN := NVL(V_SIC81.CAC047, 0) * V_SYYS; --本年积数额_剩余_个人缴纳 V_JSE_SY.HR_SHENG := NVL(V_SIC81.CAC070, 0) * V_SYYS; --本年积数额_剩余_省财政划入 V_JSE_SY.HR_SHI := NVL(V_SIC81.CAC071, 0) * V_SYYS; --本年积数额_剩余_市财政划入 V_JSE_SY.HR_QU := NVL(V_SIC81.CAC072, 0) * V_SYYS; --本年积数额_剩余_区财政划入 V_JSE_SY.HR_QTCZ := NVL(V_SIC81.CAC073, 0) * V_SYYS; --本年积数额_剩余_其它财政划入 --begin:做本年部分的利息计算 --公式:(本年已有月积数额-后续剩余月积数额 )*本年月利率 V_BNLX.YLL := V_YLL_BN; V_BNLX.DWHR := (NVL(V_SIC81.CIE579, 0) - V_JSE_SY.DWHR) * V_YLL_BN; --本年积数额_单位划入 V_BNLX.GRJN := (NVL(V_SIC81.CIE580, 0) - V_JSE_SY.GRJN) * V_YLL_BN; --本年积数额_个人缴纳 V_BNLX.HR_SHENG := (NVL(V_SIC81.CIE581, 0) - V_JSE_SY.HR_SHENG) * V_YLL_BN; --本年积数额_省财政划入 V_BNLX.HR_SHI := (NVL(V_SIC81.CIE582, 0) - V_JSE_SY.HR_SHI) * V_YLL_BN; --本年积数额_市财政划入 V_BNLX.HR_QU := (NVL(V_SIC81.CIE583, 0) - V_JSE_SY.HR_QU) * V_YLL_BN; --本年积数额_区财政划入 V_BNLX.HR_QTCZ := (NVL(V_SIC81.CIE584, 0) - V_JSE_SY.HR_QTCZ) * V_YLL_BN; --本年积数额_其它财政划入 --end:做本年部分的利息计算 --重新初始化本年部分的积数额部分(先赋值给变量,后续更新时使用) --各积数额=(当前账户余额-当年利息部分)*剩余月数 --MODIFY BY YYX 根据用户年度计息需求,年中计息的利息要作为本年度剩余月份的月积数 20120802 V_JSE_BN.DWHR := (NVL(V_SIC81.CAC046, 0) - NVL(V_SIC81.AAE263, 0) + V_BNLX.DWHR) * V_SYYS; --CIE579 本年积数额_单位划入 V_JSE_BN.GRJN := (NVL(V_SIC81.CAC047, 0) - NVL(V_SIC81.AAE265, 0) + V_BNLX.GRJN) * V_SYYS; --CIE580 本年积数额_个人缴纳 V_JSE_BN.HR_SHENG := (NVL(V_SIC81.CAC070, 0) - NVL(V_SIC81.CAC062, 0) + V_BNLX.HR_SHENG) * V_SYYS; --CIE581 本年积数额_省财政划入 V_JSE_BN.HR_SHI := (NVL(V_SIC81.CAC071, 0) - NVL(V_SIC81.CAC063, 0) + V_BNLX.HR_SHI) * V_SYYS; --CIE582 本年积数额_市财政划入 V_JSE_BN.HR_QU := (NVL(V_SIC81.CAC072, 0) - NVL(V_SIC81.CAC064, 0) + V_BNLX.HR_QU) * V_SYYS; --CIE583 本年积数额_区财政划入 V_JSE_BN.HR_QTCZ := (NVL(V_SIC81.CAC073, 0) - NVL(V_SIC81.CAC065, 0) + V_BNLX.HR_QTCZ) * V_SYYS; --CIE584 本年积数额_其它财政划入 YLGRZH_JXQBF(V_SIC81, ‘2‘, ‘‘, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --更新账户金额及计息时间点(只更新本年积数额、本年各利息字段、最后计算日期) UPDATE SIC81 SET CIE579 = V_JSE_BN.DWHR, --本年积数额_单位划入 CIE580 = V_JSE_BN.GRJN, --本年积数额_个人缴纳 CIE581 = V_JSE_BN.HR_SHENG, --本年积数额_省财政划入 CIE582 = V_JSE_BN.HR_SHI, --本年积数额_市财政划入 CIE583 = V_JSE_BN.HR_QU, --本年积数额_区财政划入 CIE584 = V_JSE_BN.HR_QTCZ, --本年积数额_其它财政划入 CAE124 = PI_JXRQ --pkg_fun.f_get_sysdate(14) WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; --调用账户收支明细事件,生成利息收入(此方法会同步账户各字段金额及余额) YLZHBGMX_LXSC(PI_AAC001, --人员ID PI_AAE140, --险种类型 V_BNLX, --利息(结构) ‘2‘, --计算类型(1为年度结息,2为年中结息) ‘bz=年中结息‘, --信息串(字段名1=值1||CHR(3)||字段名2=值2) PO_FHZ, --返回值 PO_MSG --返回消息 ); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END; --养老账户明细_计息时调用 PROCEDURE YLZHBGMX_LXSC(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型 PI_LX IN TYPE_ZHJE, --利息(结构) PI_JXLX IN VARCHAR2, --计息类型(1为年度结息,2为年中结息) PI_XXC IN VARCHAR2, --信息串(字段名1=值1||CHR(3)||字段名2=值2) PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2, --返回消息 PI_JXND IN NUMBER DEFAULT NULL --计息年度 ) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylzhbgmx_lxsc‘; V_PROCPARAMS VARCHAR2(3000); V_SIC83 SIC83%ROWTYPE; V_SIC83_W SIC83%ROWTYPE; --写入的记录 V_SIC81 SIC81%ROWTYPE; V_CAE230 VARCHAR2(6); --账户变动类型 BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxlx=‘ || PI_JXLX || ‘,pi_xxc=‘ || PI_XXC; PKG_ZHGL.YLGRZH_CX(PI_AAC001, PI_AAE140, V_SIC81, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --ADD BY YANGYIXIN 根据0625账户计息需求修改,年度计息账户写入时间和财务确认时间均为计息年度的最后一天 IF NVL(PI_JXLX, ‘0‘) = ‘1‘ THEN --年度结息 V_CAE230 := PKG_BXGX_CON.CAE230_NDJX; V_SIC83.CAE233 := PI_JXND || ‘1231‘; -- 帐户写入时间 V_SIC83.CAE683 := PI_JXND || ‘1231‘; -- 财务确认时间 ELSIF NVL(PI_JXLX, ‘0‘) = ‘2‘ THEN --年中结息 V_CAE230 := PKG_BXGX_CON.CAE230_NZJX; V_SIC83.CAE233 := PKG_FUN.F_GET_SYSDATE(14); --帐户写入时间 V_SIC83.CAE683 := V_SIC83.CAE233; -- 财务确认时间 ELSIF NVL(PI_JXLX, ‘0‘) = ‘3‘ THEN --市外转入计息 --modify by 杨逸欣 20120913 V_CAE230 := C_CAE320_SWZRJX; V_SIC83.CAE233 := PKG_FUN.F_GET_SYSDATE(14); --帐户写入时间 V_SIC83.CAE683 := V_SIC83.CAE233; -- 财务确认时间 ELSE PO_FHZ := ‘1‘; PO_MSG := ‘‘; RETURN; END IF; -- v_sic83.cae176 := NULL; --N帐户变动顺序号 V_SIC83.BAE001 := V_SIC81.BAE001; --a机构 V_SIC83.AAB001 := V_SIC81.AAB001; --组织ID@组织编号:组织唯一标识,系统生成。 V_SIC83.AAC001 := V_SIC81.AAC001; --人员ID V_SIC83.CAE177 := PKG_BXGX_CON.CAE177_QT; --收支方式@对应关系的缴费方式:自行缴费,下月台帐,对应待遇的待遇发放方式:银行正常划拨,个人帐户划拨,银行代发,农养老现金支付,异地商发其他银行划拨,农信社正常划拨,异地广发,异地信汇,异地邮汇本地信汇,送款上门,现金支付,单位银行信汇 V_SIC83.CAE178 := PKG_BXGX_CON.CAE178_SR; --收支标志@收入,支出 V_SIC83.AAE341 := NULL; --筹资项目@区分各级财务补贴、民政、残联等 V_SIC83.CAE230 := V_CAE230; --帐户变动类型@地税到账,按人数征收补录,历史维护,人员合并,收入退款,企业转机关,机关转企业,企业转农保,农保转企业,农保转机关,机关转农保,市外转入到账,市外转入转医疗,市外转入转机关,市外转入转失业,市外转入转视同,市外转入转地方养老,市外转入转个人账户,转出市外,农保到账,待遇支付,待遇支付退回,年度计息,年中计息财务调账财务调账 -- v_sic83.cae231 := NULL; --业务关键字段@缴费顺序号、待遇变更顺序号等 -- v_sic83.cae232 := NULL; --业务关键字段值@缴费顺序号、待遇变更顺序号等对应的值 V_SIC83.AAE140 := PI_AAE140; --险种类型 V_SIC83.AAC124 := NULL; --个人缴费利息 V_SIC83.AAC126 := NULL; --划入帐户利息 V_SIC83.CAE124 := NULL; --最后计息日期 V_SIC83.CAA034 := PKG_BXGX_CON.CAA034_JS; --利息计算标志@计息,不计息 --v_sic83.cae233 := pkg_fun.f_get_sysdate(14); --帐户写入时间 V_SIC83.CAE234 := V_SIC83.CAE233; --帐户计息时间 --v_sic83.CAE683 := v_sic83.cae233;-- 财务确认时间 /* v_sic83.cac074 := NULL; --累计个人缴费 v_sic83.cac075 := NULL; --累计单位划入帐户 v_sic83.cac076 := NULL; --累计个人缴费利息 v_sic83.cac077 := NULL; --累计单位缴费利息*/ V_SIC83.AAE013 := PKG_FUN.F_GET_VALUE(PI_XXC, ‘bz‘, CHR(3)); --备注 V_SIC83.CAE682 := PKG_BXGX_CON.CAE682_YLSJ; --VARCHAR2(6) Y 数据类型 --v_sic83.cae683 := NULL; --财务确认时间 /* v_sic83.cae684 := NULL; --上年度累计利息 */ V_SIC83.AAA031 := PI_LX.YLL; --利率 --利息分为6个字段,分别写入收支明细 --1.正常的,单位划入利息和个人缴费利息,放入同一条 IF NVL(PI_LX.DWHR, 0) + NVL(PI_LX.GRJN, 0) > 0 THEN V_SIC83_W := V_SIC83; V_SIC83_W.AAE341 := PKG_BXGX_CON.AAE341_ZCJF; --筹资项目 V_SIC83_W.AAC124 := NVL(PI_LX.GRJN, 0); --个人缴费利息 V_SIC83_W.AAC126 := NVL(PI_LX.DWHR, 0); --划入帐户利息 PKG_ZHGL.YLZHBGMX_SC(V_SIC83_W, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; --2.省财政划入 IF NVL(PI_LX.HR_SHENG, 0) > 0 THEN V_SIC83_W := V_SIC83; --重新赋值 V_SIC83_W.AAE341 := PKG_BXGX_CON.AAE341_SHENG; --筹资项目 V_SIC83_W.AAC126 := NVL(PI_LX.HR_SHENG, 0); --划入帐户利息 PKG_ZHGL.YLZHBGMX_SC(V_SIC83_W, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; --3.市财政划入 IF NVL(PI_LX.HR_SHI, 0) > 0 THEN V_SIC83_W := V_SIC83; --重新赋值 V_SIC83_W.AAE341 := PKG_BXGX_CON.AAE341_SHI; --筹资项目 V_SIC83_W.AAC126 := NVL(PI_LX.HR_SHI, 0); --划入帐户利息 PKG_ZHGL.YLZHBGMX_SC(V_SIC83_W, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; --4.区财政划入(放入区县) IF NVL(PI_LX.HR_QU, 0) > 0 THEN V_SIC83_W := V_SIC83; --重新赋值 V_SIC83_W.AAE341 := PKG_BXGX_CON.AAE341_XIAN; --筹资项目 V_SIC83_W.AAC126 := NVL(PI_LX.HR_QU, 0); --划入帐户利息 PKG_ZHGL.YLZHBGMX_SC(V_SIC83_W, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; --5.其它财政划入(类型定为民政) IF NVL(PI_LX.HR_QTCZ, 0) > 0 THEN V_SIC83_W := V_SIC83; --重新赋值 V_SIC83_W.AAE341 := PKG_BXGX_CON.AAE341_MZ; --筹资项目 V_SIC83_W.AAC126 := NVL(PI_LX.HR_QTCZ, 0); --划入帐户利息 PKG_ZHGL.YLZHBGMX_SC(V_SIC83_W, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END IF; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END; --养老个人账户.计息前备份 PROCEDURE YLGRZH_JXQBF(PI_SIC81 IN SIC81%ROWTYPE, --养老账户行记录 PI_JXLX IN VARCHAR2, --计息类型(1为年度结息,2为年中结息,3为年度结转) PI_BZ IN VARCHAR2, PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_jxqbf‘; V_PROCPARAMS VARCHAR2(3000); BEGIN /*\*v_procparams := ‘,传入参数为:pi_aac001=‘ ||pi_sic81.aac001 || ‘,pi_aae140=‘ || pi_sic81.aae140 || ‘,pi_jxlx=‘ || pi_jxlx || ‘,pi_bz=‘ || pi_bz; insert into ica2(BAE001,AAB001,AAC001,AAE140,CAE246,AAE262,AAE264,AAE263,AAE265,AAE253,AAE254,AAE256,AAE257,CAC046,CAC047,AAE206,CAC048,CAC052,CAC053,CAC054,CAC055,CAC056,CAC057,CAC058,CAC059,CAC060,CAC061,CAC062,CAC063,CAC064,CAC065,CAC066,CAC067,CAC068,CAC069,CAC070,CAC071,CAC072,CAC073,CAE124,CIE579,CIE580,CIE581,CIE582,CIE583,CIE584,CIE585,CIE586,CIE587,CIE588,CIE589,CIE590,jxlx,BAE003) values(pi_sic81.BAE*\001,pi_sic81.AAB001,pi_sic81.AAC001,pi_sic81.AAE140,pi_sic81.CAE246,pi_sic81.AAE262,pi_sic81.AAE264,pi_sic81.AAE263,pi_sic81.AAE265,pi_sic81.AAE253,pi_sic81.AAE254,pi_sic81.AAE256,pi_sic81.AAE257,pi_sic81.CAC046,pi_sic81.CAC047,pi_sic81.AAE206,pi_sic81.CAC048,pi_sic81.CAC052,pi_sic81.CAC053,pi_sic81.CAC054,pi_sic81.CAC055,pi_sic81.CAC056,pi_sic81.CAC057,pi_sic81.CAC058,pi_sic81.CAC059,pi_sic81.CAC060,pi_sic81.CAC061,pi_sic81.CAC062,pi_sic81.CAC063,pi_sic81.CAC064,pi_sic81.CAC065,pi_sic81.CAC066,pi_sic81.CAC067,pi_sic81.CAC068,pi_sic81.CAC069,pi_sic81.CAC070,pi_sic81.CAC071,pi_sic81.CAC072,pi_sic81.CAC073,pi_sic81.CAE124,pi_sic81.CIE579,pi_sic81.CIE580,pi_sic81.CIE581,pi_sic81.CIE582,pi_sic81.CIE583,pi_sic81.CIE584,pi_sic81.CIE585,pi_sic81.CIE586,pi_sic81.CIE587,pi_sic81.CIE588,pi_sic81.CIE589,pi_sic81.CIE590,pi_jxlx,pkg_fun.f_get_sysdate(14));*/ PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END; PROCEDURE YLGRZH_CESUAN(PI_AAC001 IN NUMBER, --人员ID PI_AAE140 IN VARCHAR2, --险种类型(如果传入0,则表示测算参保人所有正常的养老账种;否则就测试传入的险种) PI_JXND IN NUMBER, --结息年度 PI_AAE011 IN VARCHAR2, PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回信息 ) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_jxqbf‘; V_PROCPARAMS VARCHAR2(3000); V_ZHZT_ZC SKC81.CAE246%TYPE := PKG_FUN.F_GET_DICT(‘CAE246‘, ‘ZC‘); --账户状态常量账户状态_正常 V_SIC81_Q SIC81%ROWTYPE; --前 V_SIC81_H SIC81%ROWTYPE; --后 V_ACA8 ACA8%ROWTYPE; --个人年度账户临时表 V_NHJXJE NUMBER(16, 2) := 0; --年后计息金额,记录年后计息例如201202进行2011年度利息计算,本年(2011年)需要剔除201201的已缴记录 --获取账户状态_正常综合参数 CURSOR C_XZ IS SELECT * FROM SIC81 WHERE AAC001 = PI_AAC001 AND (AAE140 = PI_AAE140 OR PI_AAE140 = ‘0‘) AND CAE246 = V_ZHZT_ZC; BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxnd=‘ || PI_JXND || ‘,pi_aae011=‘ || PI_AAE011; DELETE ACA8 WHERE AAC001 = PI_AAC001 AND AAE001 = PI_JXND; PO_FHZ := 1; FOR V_XZ IN C_XZ LOOP --先记录计息前的状态 SELECT * INTO V_SIC81_Q FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = V_XZ.AAE140; --回滚点 SAVEPOINT SP_JXQ; --调用pkg_zhgl.ylgrzh_grndjx PKG_ZHGL.YLGRZH_GRNDJX(V_XZ.AAC001, V_XZ.AAE140, TO_NUMBER(SUBSTR(PI_JXND, 1, 4)), PI_AAE011, ‘‘, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --获取该险种的sic81行记录 SELECT * INTO V_SIC81_H FROM SIC81 WHERE AAC001 = PI_AAC001 AND AAE140 = V_XZ.AAE140; --事务回滚至回滚点 ROLLBACK TO SP_JXQ; --将sic81行记录的值,插入养老账户测算表 --年后计息金额,记录年后计息例如201202进行2011年度利息计算,本年(2011年)需要剔除201201的已缴记录 SELECT NVL(SUM(NVL(AAC123, 0) + NVL(AAC125, 0)), 0) INTO V_NHJXJE FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = V_XZ.AAE140 AND SUBSTR(CAE121, 1, 4) > PI_JXND; --根据计息前后计算差额插入aca8表 SELECT SEQ_BXGX_CAZ533.NEXTVAL INTO V_ACA8.CAZ533 FROM DUAL; V_ACA8.AAC001 := V_SIC81_Q.AAC001; V_ACA8.AAE140 := V_SIC81_Q.AAE140; V_ACA8.AAE001 := PI_JXND; V_ACA8.CAE691 := ‘1‘; --1为年度结息,2为年中结息,3为年度结转 V_ACA8.CAE692 := ‘1‘; --上年末个人账户累计本金 V_ACA8.AAE474 := NVL(V_SIC81_Q.AAE253, 0) + NVL(V_SIC81_Q.AAE254, 0); --上年末个人账户累计利息 V_ACA8.AAE475 := NVL(V_SIC81_Q.AAE256, 0) + NVL(V_SIC81_Q.AAE257, 0); --上年末账户本息在本年产生的利息=sic_h.上年末本息-sic_q.上年末本息-sic_q.上年缴费划入利息 V_ACA8.AAE476 := (NVL(V_SIC81_H.AAE253, 0) + NVL(V_SIC81_H.AAE254, 0) + NVL(V_SIC81_H.AAE256, 0) + NVL(V_SIC81_H.AAE257, 0)) - (NVL(V_SIC81_Q.AAE253, 0) + NVL(V_SIC81_Q.AAE254, 0) + NVL(V_SIC81_Q.AAE256, 0) + NVL(V_SIC81_Q.AAE257, 0)) - (NVL(V_SIC81_Q.AAE263, 0) + NVL(V_SIC81_Q.AAE265, 0)); --本年个人账户本金 V_ACA8.AAE477 := NVL(V_SIC81_Q.AAE262, 0) + NVL(V_SIC81_Q.AAE264, 0) - V_NHJXJE; --本年个人账户本金在本年产生的利息 V_ACA8.AAE478 := NVL(V_SIC81_Q.AAE263, 0) + NVL(V_SIC81_Q.AAE265, 0); V_ACA8.CAE693 := PI_JXND; --暂时用这个 V_ACA8.AAE013 := ‘‘; INSERT INTO ACA8 VALUES V_ACA8; END LOOP; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END; --养老账户变更明细_转出市外 PROCEDURE YLZHBGMX_ZCSW(PI_AAZ163 IN NUMBER, --个人变更记录号 PI_SAC13 IN SAC13%ROWTYPE, PI_BHE949 IN NUMBER, PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回消息 ) IS V_SIC83 SIC83%ROWTYPE; V_PARAMS VARCHAR2(2000); --传入参数串 V_PROCNAME VARCHAR2(50) := C_PKG_NAME || ‘ylstzh_xgzhzt‘; -- 过程名 V_CAC046 SIC81.CAC046%TYPE; V_CAC047 SIC81.CAC047%TYPE; V_SIC81 SIC81%ROWTYPE; V_HRZHJE_06 NUMBER(12, 2); BEGIN V_PARAMS := ‘,传入参数为:pi_aaz163=‘ || PI_AAZ163 || ‘,pi_bhe949=‘ || PI_BHE949; PO_FHZ := ‘1‘; --调用序列发生器SEQ_BXGX_CAE176生成帐户变更顺序号,并赋值给v_zhbgmx SELECT SEQ_BXGX_CAE176.NEXTVAL INTO V_SIC83.CAE176 FROM DUAL; --获取养老个人账户情况 SELECT * INTO V_SIC81 FROM SIC81 WHERE AAC001 = PI_SAC13.AAC001 AND AAE140 = PI_SAC13.AAE140; V_SIC83.AAC123 := -NVL(V_SIC81.CAC047, 0); --个人缴纳总额 V_SIC83.AAC125 := - (NVL(PI_SAC13.AIC083, 0) - NVL(V_SIC81.CAC047, 0)); --单位划入总额 --初始化SIC83 V_SIC83.BAE001 := PI_SAC13.BAE001; --a机构 V_SIC83.AAB001 := PI_SAC13.AAB001; --组织ID@ V_SIC83.AAC001 := PI_SAC13.AAC001; --人员ID V_SIC83.CAE177 := C_CAE177_YHZCHZ; --收支方式@银行正常划拨 V_SIC83.CAE178 := C_CAE178_ZC; --收支标志@收入,支出 V_SIC83.AAE341 := C_AAE341_ZCJF; --筹资项目@ V_SIC83.CAE230 := C_CAE230_ZCSW; --帐户变动类型 V_SIC83.CAE231 := ‘AAZ163‘; --业务关键字段@ V_SIC83.CAE232 := PI_AAZ163; --业务关键字段值@ V_SIC83.AAE140 := PI_SAC13.AAE140; --险种类型 --v_sic83.AAC123 := -NVL(pi_sac13.AIC089,0) ; --个人缴费金额 --v_sic83.AAC125 := -NVL(pi_sac13.AIC082,0) ; --划入帐户金额 V_SIC83.AAC127 := -NVL(PI_SAC13.AIC084, 0); --划入统筹金额 V_SIC83.AAC124 := 0; --个人缴费利息 V_SIC83.AAC126 := 0; --划入帐户利息 V_SIC83.AAC128 := 0; --划入统筹利息 V_SIC83.CAA034 := C_CAA034_BJS; --利息计算标志@计息,不计息 V_SIC83.CAE233 := PI_BHE949; --帐户写入时间 V_SIC83.AAE013 := ‘转出市外生成支出的账户变更明细‘; --备注 V_SIC83.CAE682 := C_CAE682_ELSJ; --数据类型 V_SIC83.CAE683 := PI_BHE949; --财务确认时间 V_SIC83.CAE684 := 0; --上年度累计利息 V_SIC83.AAA031 := 0; --利率 --生成SIC83 INSERT INTO SIC83 VALUES V_SIC83; --企业养老200601-200606之间存在单位划入账户部分,此部分金额保留在养老个人账户中 IF PI_SAC13.AAE140 = ‘110‘ THEN SELECT NVL(SUM(NVL(AAC125, 0)), 0) INTO V_CAC046 FROM SIC84 WHERE AAC001 = PI_SAC13.AAC001 AND AAE140 = PI_SAC13.AAE140 AND CAE121 >= 200601 AND CAE121 <= 200606; ELSE V_CAC046 := 0; END IF; --修改养老个人账户,扣减转移金额 UPDATE SIC81 SET CAC046 = V_CAC046, --单位划入余额 CAC047 = 0 --个人缴纳余额 WHERE AAC001 = PI_SAC13.AAC001 AND AAE140 = PI_SAC13.AAE140; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘PKG_ZHGL.Ylzhbgmx_blls_99‘; -- 请查看详细出错信息 PO_MSG := ‘调用"PKG_ZHGL.Ylzhbgmx_blls"时系统错误,传入参数为:‘ || ‘pi_aaz163:‘ || PI_AAZ163 || ‘错误信息是:‘ || SQLERRM || ‘。‘; END YLZHBGMX_ZCSW; /* ADD BY YANGYIXIN 20120913 市外转入中途计息 账户计息开始时间为转入财务收入到账确认时间当年的1月1日; 账户计息终止时间为转入业务复核时系统的本地个人帐户计息的截止时点; */ --养老个人账户.市外转入中途计息 PROCEDURE YLGRZH_SWZRZTJX(PI_AAC001 IN NUMBER, --人员ID PI_BAE007 IN VARCHAR2, --业务流水号 PI_AAE011 IN VARCHAR2, --经办人(预留后面生成账户变动记录) PI_XXC IN VARCHAR2, --信息串(字段名1=值1||CHR(3)||字段名2=值2) PO_FHZ OUT VARCHAR2, --返回值 PO_MSG OUT VARCHAR2 --返回信息 ) IS V_PROCNAME VARCHAR2(100) := ‘ylgrzh_swzrztjx‘; V_PROCPARAMS VARCHAR2(3000); V_SIC81 SIC81%ROWTYPE; V_ZHJXRQ VARCHAR2(14); V_SNLX TYPE_ZHJE; --上年利息(结构) V_BNLX TYPE_ZHJE; --本年利息(结构) V_JSE_BN TYPE_ZHJE; --本年积数额(结构) V_JSE_SY TYPE_ZHJE; --本年积数额_剩余(结构) V_YLL_SN NUMBER; --上年月利率 V_YLL_BN NUMBER; --本年月利率 V_SYYS NUMBER; V_BZ VARCHAR2(100); --备注 V_JXRQ DATE; V_CAE149 NUMBER; V_JXKSSJ NUMBER; V_JXZZSJ NUMBER; V_JXKSND NUMBER; V_JXZZND NUMBER; V_JXND NUMBER; V_JZLX NUMBER(14, 2); --确定本次转移险种信息 CURSOR C_SAC13 IS SELECT B.* FROM SAC12 A, SAC13 B WHERE A.AAC001 = B.AAC001 AND A.BAE007 = B.BAE007 AND A.BAE007 = PI_BAE007 AND A.AAC001 = PI_AAC001 AND A.AAE140 LIKE ‘1%‘ AND A.BCE326 = ‘1‘; BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae011=‘ || PI_AAE011 || ‘,pi_xxc=‘ || PI_XXC; --根据转移险种信息循环处理 FOR V_SAC13 IN C_SAC13 LOOP --获取养老个人账户 PKG_ZHGL.YLGRZH_CX(PI_AAC001, V_SAC13.AAE140, V_SIC81, PO_FHZ, PO_MSG); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; IF V_SIC81.CAE246 = ‘2‘ THEN PO_FHZ := V_PROCNAME || ‘_300‘; PO_MSG := ‘参保人账户已经注销,不允许做中途结息.‘ || V_PROCPARAMS; RETURN; END IF; --20120419 Jinqingyu 添加校验(如果账户余额为0,则不再计息;如果为负数,则抛出异常) IF NVL(V_SIC81.CAC046, 0) + NVL(V_SIC81.CAC047, 0) = 0 THEN PO_FHZ := ‘1‘; RETURN; END IF; --确定账户计息起止时间 --账户计息开始时间为转入财务收入到账确认时间当年的1月1日; --账户计息终止时间为转入业务复核时系统的本地个人帐户计息的截止时点; --举例说明:参保人转入金额是2009年5月到账的,在2011年10月办理了转入复核,那么计息开始时间应该为 --2009年1月1日,计息终止时间应该为2011年10月当时系统的个人帐户利息结息的终止时点,即2010年12月31日。 --确定转入收入财务确认时间,取SAD07.CAE149 --如果无财务收入记录,则默认为系统当天,表示不用计息 BEGIN SELECT NVL(CAE149, AAD017) INTO V_CAE149 FROM SAD07 WHERE CAE011 = V_SAC13.CAE011; EXCEPTION WHEN NO_DATA_FOUND THEN V_CAE149 := PKG_FUN.F_GET_SYSDATE(8); --取系统日期 END; --如果到账日期大于参保人计息日期,则不用处理 --如果到账小于账户计息日期,则按前面的规则确定计息起止时间 IF V_CAE149 >= TO_NUMBER(SUBSTR(V_SIC81.CAE124, 1, 8)) THEN RETURN; ELSE --计息开始时间为到账当年的1月1日 V_JXKSSJ := TO_NUMBER(SUBSTR(V_CAE149, 1, 4) || ‘0101‘); --确定计息终止时间 IF SUBSTR(V_SIC81.CAE124, 5, 8) = ‘1231‘ THEN V_JXZZSJ := TO_NUMBER(SUBSTR(V_SIC81.CAE124, 1, 8)); ELSE --计息截止时间上年度的最后一天 V_JXZZSJ := TO_NUMBER((TO_NUMBER(SUBSTR(V_SIC81.CAE124, 1, 4)) - 1) || ‘1231‘); END IF; --确定计息开始年度和计息终止年度 V_JXKSND := TO_NUMBER(SUBSTR(V_JXKSSJ, 1, 4)); V_JXZZND := TO_NUMBER(SUBSTR(V_JXZZSJ, 1, 4)); V_JXND := V_JXKSND; V_JZLX := 0; --分开年度计息 WHILE V_JXND <= V_JXZZND LOOP --获取计息年度的利率 PKG_ZSCS.GETJZLL(V_SIC81.BAE001, --a机构 V_SIC81.AAE140, --险种类型 PKG_BXGX_CON.AAA030_JZNLL, --利率滞纳金类型@年利率,月利率,滞纳金利率 SUBSTRB(V_JXND, 1, 4) || ‘0101‘, --计息日期 V_YLL_BN, --a记账利率 PO_FHZ, --返回值 PO_MSG --返回信息 ); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; --计算利息 V_JZLX := V_JZLX + ROUND((V_SAC13.AIC083 + V_JZLX) * V_YLL_BN, 2); V_JXND := V_JXND + 1; END LOOP; --计息备份 PKG_ZHGL.YLGRZH_JXQBF(V_SIC81, ‘3‘, ‘‘, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_BNLX.DWHR := 0; --单位划入 V_BNLX.GRJN := V_JZLX; --个人缴纳 V_BNLX.HR_SHENG := 0; --省财政划入 V_BNLX.HR_SHI := 0; --市财政划入 V_BNLX.HR_QU := 0; --区财政划入 V_BNLX.HR_QTCZ := 0; --其它财政划入 V_BNLX.YLL := 0; --使用的利率 --更新上年积数额_个人缴纳 UPDATE SIC81 SET CIE586 = NVL(CIE586, 0) + V_JZLX * 12 WHERE AAC001 = PI_AAC001 AND AAE140 = V_SAC13.AAE140; --生成账户变更明细 --调用账户收支明细事件,生成利息收入(此方法会同步账户各字段金额及余额) PKG_ZHGL.YLZHBGMX_LXSC(PI_AAC001, --人员ID V_SAC13.AAE140, --险种类型 V_BNLX, --利息(结构) ‘3‘, --计算类型(1为年度结息,2为年中结息,3市外转入中途计息) ‘bz=市外转入中途计息‘, --信息串(字段名1=值1||CHR(3)||字段名2=值2) PO_FHZ, --返回值 PO_MSG --返回消息 ); IF PO_FHZ <> ‘1‘ THEN RETURN; END IF; END IF; END LOOP; PO_FHZ := ‘1‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END YLGRZH_SWZRZTJX; PROCEDURE YLGRZH_CXTJ(PI_AAC001 IN VARCHAR2, PI_AAE140 IN VARCHAR2, PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS /* ----养老账户重新统计 a 2013.5.17 a 2013.10.05 增加失地农民一次性缴费的计息 a 2013.10.09 1990~1992年的实缴月数修改 90~91年 写 0,92年 写9 a 2013.10.12 由于老系统中转移的账户每年都记录了,所以只有转移的最后一年才能开始计息(先不考虑多地转入的情况) a 2013.10.14 在1993年至1995年有很多人只有本地参保历史但却没有实缴记录,其年度缴费基数和月数通过历史统计 a 2013.12.04 账户计息,按本地、转移、一次性单独处理计息,这样可能要好处理一点,只是在最后的一年,处理SIC81 转移的只从最后转移的那年开始计息, a 2013.12.24 增加一次性缴费的最小记账年份,防止失地农民一次性缴费后就直接退休 a 2013.12.27 一次性缴费需确定缴费到账日期,用于记录当年的记账利息 a 2014.4.10 养老退休一次性趸交与失地农民一次性趸交的相同 a 2014.9.4 将一次性趸缴的统一处理 a 2014.9.25 若计息月份为负数(因系统有到账日期的年度比账户年度大的情况)---此类只存在于一次性趸交的导入的情况 a 2014.10.10 统计缴费月数时,调整性补收的不算 */ V_GRJNYE NUMBER(10, 2); V_DWHRYE NUMBER(10, 2); V_GRLJ NUMBER(10, 2); V_ZHLJ NUMBER(10, 2); V_ZHRQ NUMBER(6); V_MINNF NUMBER(4); --参保历史的最小年份 V_MINNF1 NUMBER(4); --转移历史的最大年份 V_MINNF2 NUMBER(4); --一次性缴费的最小年份 N_JZQJFLS NUMBER; N_JZQJFJE NUMBER(10, 2); N_JFNF NUMBER; N_GRJFJE NUMBER(10, 2); N_HRZHJE NUMBER(10, 2); N_DQLL NUMBER(4, 4); N_HQLL NUMBER(4, 4); R_ZH_ND SIC86%ROWTYPE; R_ZH_ZR SIC86%ROWTYPE; R_ZH_YCX SIC86%ROWTYPE; R_SIC81 SIC81%ROWTYPE; N_SHNF NUMBER(4); V_LJHRLX NUMBER(10, 2); V_LJJNLX NUMBER(10, 2); V_DWJS NUMBER(16, 2); --单位划入部分月积数 V_GRJS NUMBER(16, 2); --个人缴费部分月积数 V_ZR_COUNT NUMBER; V_LS_COUNT NUMBER; V_MSG VARCHAR2(1000); V_COUNT NUMBER; V_RYJBZL PKG_PUB.REC_RYJBZL; --个人基本资料 V_AIC042_SN NUMBER(4); --截止上年末累计缴费月数_上年 V_CIC818_SN NUMBER(4); --本年实缴月数_上年 V_AIC042 NUMBER(4); --截止上年末累计缴费月数 V_CIC819 NUMBER(12, 2); --本年缴费基数和 V_CIC818 NUMBER(4); --本年实缴月数 V_YS NUMBER; V_ZHZY_JXKDND NUMBER(4); ---转移账户计息开始年度 V_ZHJXRQ NUMBER(8); V_COUNT_YCXJF NUMBER; ---一次性缴费年度账户 ---转入的年度账户(可能会存在一年里有多个地方转入的情况) CURSOR C_NDZH(C_ZHND NUMBER) IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘ AND AAE001 = C_ZHND; ----获取失地农民一次性缴费所产生的账户 a 2013.10.05 ---获取养老退休一次性趸交 CURSOR C_NDZH_NMYCX(C_ZHND NUMBER) IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 NOT IN (‘0‘, ‘1‘) AND AAE001 = C_ZHND; BEGIN V_ZHZY_JXKDND := 0; IF PI_AAE140 NOT IN (‘110‘, ‘120‘) THEN PO_FHZ := ‘1‘; RETURN; END IF; V_ZR_COUNT := 0; V_MINNF := 0; V_MINNF1 := 0; --查询当前个人基本信息 PKG_BXGX_SHARE.GET_RYJBZL(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_MSG := ‘‘; ---删除非转入的年度缴费资料 DELETE SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND NVL(AAE087, ‘0‘) = ‘0‘; BEGIN ---查询本地缴费历史 SELECT COUNT(1) INTO V_LS_COUNT FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND NVL(AAC402, ‘0‘) <> ‘1‘; --转移的参保历史除外 IF V_LS_COUNT > 0 THEN ---查询最小参保历史年度及年月 SELECT MIN(AAE041), MIN(SUBSTR(AAE041, 1, 4)) INTO V_ZHRQ, V_MINNF FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND NVL(AAC402, ‘0‘) <> ‘1‘; --转移的参保历史除外 END IF; ---判断是否有转入的年度账户 SELECT COUNT(1) INTO V_LS_COUNT FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘; --查询转移的年度帐户 --如果有转入的年度账户,则获取最近的转入年度 IF V_LS_COUNT > 0 THEN SELECT MAX(AAE001) INTO V_MINNF1 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘; --查询转移的年度帐户 V_ZHZY_JXKDND := V_MINNF1; ----防止一年中有多条转入记录的情况 a 2013.11.26 SELECT MAX(NVL(AIC081, 0)) INTO V_ZHJXRQ FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘ AND AAE001 = V_ZHZY_JXKDND; ---如果转入的账户已经计息,则转入的最大年度不作计息处理 a 2013.10.22 IF SUBSTR(V_ZHJXRQ, 1, 4) >= V_MINNF1 THEN V_MINNF1 := V_MINNF1 + 1; END IF; END IF; ---如果没有本地的参保历史和转入的账户记录以及一次性缴费账户,则个人账户全部设置为0,并结束改过程 SELECT COUNT(1), NVL(MIN(AAE001), 0) INTO V_COUNT_YCXJF, V_MINNF2 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 NOT IN (‘0‘, ‘1‘); IF V_MINNF1 = 0 AND V_MINNF = 0 AND V_COUNT_YCXJF = 0 THEN UPDATE SIC81 SET AAE262 = 0, AAE264 = 0, AAE263 = 0, AAE265 = 0, AAE253 = 0, AAE254 = 0, AAE256 = 0, AAE257 = 0, CAC046 = 0, CAC047 = 0 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; PO_FHZ := ‘1‘; RETURN; END IF; --保证从最早的帐户年度处理开始处理(若转入的年度已经计息,则不处理) IF V_MINNF1 < V_MINNF AND (V_MINNF1 > 0 AND V_ZHJXRQ = 0) THEN V_MINNF := V_MINNF1; ELSE IF V_MINNF = 0 THEN V_MINNF := V_MINNF1; END IF; END IF; ---判断一次性缴费的最小年份是不是整个历史的最小年份 a 2013.12.24 IF V_MINNF = 0 AND V_MINNF2 > 0 THEN V_MINNF := V_MINNF2; ELSIF V_MINNF2 > 0 AND V_MINNF2 < V_MINNF THEN V_MINNF := V_MINNF2; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := ‘个人编号为‘ || PI_AAC001 || ‘的个人帐户重新统计时查询养老参保历史出错!‘; RETURN; END; ----如果账户建立日期小于199601,则为 199601; IF V_ZHRQ < 199601 THEN V_ZHRQ := 199601; END IF; SELECT TO_CHAR(SYSDATE, ‘YYYY‘) INTO N_SHNF FROM DUAL; R_ZH_ND.AAC001 := PI_AAC001; R_ZH_ND.AAE140 := PI_AAE140; R_ZH_ND.BAE001 := V_RYJBZL.BAE001; R_ZH_ND.AAB001 := V_RYJBZL.AAB001; R_ZH_ND.AAE087 := ‘0‘; R_ZH_ND.AAE035 := 0; ---保证从1990年开始 IF V_MINNF < 1990 THEN V_MINNF := 1990; END IF; FOR N_JFNF IN V_MINNF .. N_SHNF LOOP ---由于账户重新统计是逐年计利息,所以若是一次性补缴多年的,其补缴的利息不在这里计入账户 ---a 2014.4.11 不含养老退休一次性趸交的 SELECT NVL(SUM(AAC123), 0), NVL(SUM(AAC125), 0), -- Count(Distinct Cae121), NVL(SUM(DECODE(AAA115, ‘34‘, 0, ‘35‘, 0, ‘39‘, 0, ‘106‘, 0, 1)), 0), NVL(SUM(AAE180), 0) INTO N_GRJFJE, N_HRZHJE, V_CIC818, V_CIC819 FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND BCE094 = ‘1‘ AND SUBSTR(CAE121, 1, 4) = N_JFNF AND AAA115 NOT IN (‘90‘, ‘91‘, ‘40‘, ‘41‘); ---不含转入生成的实缴记录 IF V_CIC818 > 12 THEN V_CIC818 := 12; END IF; R_ZH_ND.AAE001 := N_JFNF; R_ZH_ND.AIC058 := N_HRZHJE; R_ZH_ND.AIC072 := N_GRJFJE; ------设置本年实缴月数、本年缴费基数和 1990~1992 从历史中获取 a 2013.10.12 IF N_JFNF IN (1990, 1991) THEN IF N_JFNF IN (1990, 1991) THEN V_CIC818 := 0; END IF; SELECT SUM((MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) * AAE180) INTO V_CIC819 FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(AAE041, 1, 4) = N_JFNF; END IF; ---在1992年至1995年有很多人只有本地参保历史但却没有实缴记录,其年度缴费基数和月数通过历史统计 IF N_JFNF IN (1992, 1993, 1994, 1995) THEN SELECT SUM((MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) * AAE180), SUM(MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) INTO V_CIC819, V_CIC818 FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 ---a 只统计本地缴费部分 2014.9.24 AND NVL(AAC402, ‘0‘) = ‘0‘ AND SUBSTR(AAE041, 1, 4) = N_JFNF; IF N_JFNF = 1992 THEN IF V_CIC818 > 9 THEN V_CIC818 := 9; END IF; END IF; END IF; R_ZH_ND.CIC818 := V_CIC818; R_ZH_ND.CIC819 := V_CIC819; --取利率 ---企业养老从1996年1月开始计息,本市采用月积数法,所以只获取年记账年利率 ----如果是机关事业养老,则从2003年1月开始计算利息 IF (PI_AAE140 = ‘120‘ AND N_JFNF < 2003) OR (PI_AAE140 = ‘110‘ AND N_JFNF < 1996) THEN N_HQLL := 0; N_DQLL := 0; ELSE BEGIN ---获取年记账利率 SELECT AAA031 / 100 INTO N_DQLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = N_JFNF || ‘0101‘ AND AAE031 = N_JFNF || ‘1231‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := N_JFNF || ‘年度记帐利率参数缺少,请设置!‘; RETURN; END; END IF; IF N_SHNF = N_JFNF THEN --当年不计任何利息 R_ZH_ND.AIC074 := 0; R_ZH_ND.AIC075 := 0; R_ZH_ND.AIC076 := 0; R_ZH_ND.AIC077 := 0; ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳 -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC079), 0) INTO R_ZH_ND.AIC041 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); --个人缴纳累计金额(本金和利息)=历年个人本金+历年个人利息+本年个人本金+本年个人利息 R_ZH_ND.AIC079 := R_ZH_ND.AIC041 + R_ZH_ND.AIC076 + R_ZH_ND.AIC075 + R_ZH_ND.AIC072; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息、历年单位划入 -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC078), 0) INTO R_ZH_ND.AIC040 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); ---获取上年度的累计缴费月数和当年缴费月数,计入本年度的累计缴费月数 (a 2013.09.28) SELECT NVL(SUM(AIC042), 0), NVL(SUM(CIC818), 0) INTO V_AIC042_SN, V_CIC818_SN FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); --and AAE087 = ‘0‘; ---截止上年末累计缴费月数 R_ZH_ND.AIC042 := V_AIC042_SN + V_CIC818_SN; R_ZH_ND.AIC078 := R_ZH_ND.AIC040 + R_ZH_ND.AIC077 + R_ZH_ND.AIC058 + R_ZH_ND.AIC074; ELSE --获取审核年度的利息积数 SELECT NVL(SUM((NVL(AAC123, 0)) * (N_JFNF || ‘12‘ - CAE121 + 1)), 0), NVL(SUM((NVL(AAC125, 0)) * (N_JFNF || ‘12‘ - CAE121 + 1)), 0) INTO V_GRJS, V_DWJS FROM SIC84 WHERE AAC001 = PI_AAC001 AND CAE121 BETWEEN N_JFNF || ‘01‘ AND N_JFNF || ‘12‘ AND AAE140 = PI_AAE140 AND AAA115 NOT IN (‘90‘, ‘91‘); ---不含转入生成的实缴记录 ---记账利率*当年利息积数/12 () R_ZH_ND.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_ND.AIC074 := N_DQLL * V_DWJS / 12; --本年缴费划入利息 ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC079), 0) * N_DQLL, NVL(SUM(AIC079), 0) INTO R_ZH_ND.AIC076, R_ZH_ND.AIC041 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); --个人缴纳累计金额(本金和利息)=历年个人本金+历年个人利息+本年个人本金+本年个人利息 R_ZH_ND.AIC079 := R_ZH_ND.AIC041 + R_ZH_ND.AIC076 + R_ZH_ND.AIC075 + R_ZH_ND.AIC072; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息、历年单位划入 (含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC078), 0) * N_DQLL, NVL(SUM(AIC078), 0) INTO R_ZH_ND.AIC077, R_ZH_ND.AIC040 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); R_ZH_ND.AIC078 := R_ZH_ND.AIC040 + R_ZH_ND.AIC077 + R_ZH_ND.AIC058 + R_ZH_ND.AIC074; ---获取上年度的累计缴费月数和当年缴费月数,计入本年度的累计缴费月数 (a 2013.09.28) SELECT NVL(SUM(AIC042), 0), NVL(SUM(CIC818), 0) INTO V_AIC042_SN, V_CIC818_SN FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); --and AAE087 = ‘0‘; ---截止上年末累计缴费月数 R_ZH_ND.AIC042 := V_AIC042_SN + V_CIC818_SN; --处理本年度的转入帐户利息--只计转入年度的利息,之前的不计,之所以用循环,是考虑同时从多地转入 ---已经记过利息的不再计息 IF N_JFNF = V_ZHZY_JXKDND AND V_ZHJXRQ = 0 THEN FOR V_NDZH_ZR IN C_NDZH(N_JFNF) LOOP SELECT * INTO R_ZH_ZR FROM SIC86 WHERE AAC001 = V_NDZH_ZR.AAC001 AND AAE140 = V_NDZH_ZR.AAE140 AND AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; ---如果转入日期没有记载,则当年不计息 IF NVL(R_ZH_ZR.AAE035, 0) = 0 THEN V_YS := 0; ELSE V_YS := N_JFNF || 12 - SUBSTR(R_ZH_ZR.AAE035, 1, 6) + 1; IF V_YS > 12 THEN V_YS := 12; END IF; END IF; ----只有计息月数大于0(及在新系统中办理的才算当年利息)a 2013.10.22 IF V_YS > 0 THEN V_GRJS := NVL(R_ZH_ZR.AIC072, 0) * V_YS; V_DWJS := NVL(R_ZH_ZR.AIC058, 0) * V_YS; R_ZH_ZR.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_ZR.AIC074 := N_DQLL * V_DWJS / 12; UPDATE SIC86 SET AIC075 = R_ZH_ZR.AIC075, AIC074 = R_ZH_ZR.AIC074, AIC078 = R_ZH_ZR.AIC074 + R_ZH_ZR.AIC058, AIC079 = R_ZH_ZR.AIC075 + R_ZH_ZR.AIC072 WHERE AAC001 = V_NDZH_ZR.AAC001 AND AAE140 = V_NDZH_ZR.AAE140 AND AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; END IF; --end 处理非本年度的转入(市外转入或者险种转移)帐户利息 END LOOP; END IF; --处理本年度的失地农民的一次性缴费帐户利息 a2013.10.05 FOR V_NDZH_YCX IN C_NDZH_NMYCX(N_JFNF) LOOP SELECT * INTO R_ZH_YCX FROM SIC86 WHERE AAC001 = V_NDZH_YCX.AAC001 AND AAE140 = V_NDZH_YCX.AAE140 AND AAE001 = V_NDZH_YCX.AAE001 AND AAE087 = V_NDZH_YCX.AAE087 AND AAE035 = V_NDZH_YCX.AAE035; ---确定一次性缴费的到账日期 a 2013.12.27 IF NVL(R_ZH_YCX.AAE035, 0) = 0 THEN V_YS := 0; ELSE V_YS := N_JFNF || 12 - SUBSTR(R_ZH_YCX.AAE035, 1, 6) + 1; IF V_YS > 12 THEN V_YS := 12; END IF; ---a 2014.9.25 计息月数小于0,则以0计 IF V_YS < 0 THEN V_YS := 0; END IF; END IF; ---v_ys := n_jfnf||12 - substr(r_zh_ycx.AAE035,1,6) + 1; V_GRJS := NVL(R_ZH_YCX.AIC072, 0) * V_YS; V_DWJS := NVL(R_ZH_YCX.AIC058, 0) * V_YS; R_ZH_YCX.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_YCX.AIC074 := N_DQLL * V_DWJS / 12; -- r_zh_ycx.AIC075 := nvl(n_dqll * (r_zh_ycx.AIC072*(n_jfnf||12 - substr(r_zh_ycx.AAE035,1,6) + 1))/12,0); --本年缴费个人利息 -- r_zh_ycx.AIC074 := nvl(n_dqll * (r_zh_ycx.AIC058*(n_jfnf||12 - substr(r_zh_ycx.AAE035,1,6) + 1))/12,0); --本年缴费划入利息 UPDATE SIC86 SET AIC075 = R_ZH_YCX.AIC075, AIC074 = R_ZH_YCX.AIC074, AIC078 = NVL(R_ZH_YCX.AIC074, 0) + NVL(R_ZH_YCX.AIC058, 0), AIC079 = NVL(R_ZH_YCX.AIC075, 0) + NVL(R_ZH_YCX.AIC072, 0) WHERE AAC001 = V_NDZH_YCX.AAC001 AND AAE140 = V_NDZH_YCX.AAE140 AND AAE001 = V_NDZH_YCX.AAE001 AND AAE087 = V_NDZH_YCX.AAE087 AND AAE035 = V_NDZH_YCX.AAE035; END LOOP; END IF; INSERT INTO SIC86 VALUES R_ZH_ND; END LOOP; ---计息完毕后,最后一年的年度账户即为参保人员的当前账户 ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC058), 0) BNBJDW, NVL(SUM(AIC072), 0) BNBJGR, NVL(SUM(AIC074), 0) BNDWLX, NVL(SUM(AIC075), 0) BNGRLX, NVL(SUM(AIC078), 0) DWHRYE, NVL(SUM(AIC079), 0) GRJNYE, NVL(SUM(AIC040), 0), NVL(SUM(AIC041), 0) INTO R_SIC81.AAE262, R_SIC81.AAE264, R_SIC81.AAE263, R_SIC81.AAE265, R_SIC81.CAC046, R_SIC81.CAC047, R_SIC81.AAE253, R_SIC81.AAE254 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE001 = N_SHNF AND AAE140 = PI_AAE140; ---历年账户(只去本地业务产生-仅有一条) /* select nvl(aic040,0),nvl(aic041,0) into r_sic81.AAE253,r_sic81.AAE254 from sic86 where aac001 = pi_aac001 and aae001 = n_shnf and aae140 = pi_aae140 and AaE087 = ‘0‘; */ ----增加计息时间 a 2013.10.1 R_SIC81.CAE124 := TO_CHAR(SYSDATE, ‘yyyymmddhh24miss‘); UPDATE SIC81 SET AAE262 = R_SIC81.AAE262, AAE264 = R_SIC81.AAE264, AAE263 = R_SIC81.AAE263, AAE265 = R_SIC81.AAE265, CAC046 = R_SIC81.CAC046, CAC047 = R_SIC81.CAC047, AAE253 = R_SIC81.AAE253, AAE254 = R_SIC81.AAE254, CAE124 = R_SIC81.CAE124 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; IF SQL%NOTFOUND THEN R_SIC81.BAE001 := V_RYJBZL.BAE001; R_SIC81.AAB001 := V_RYJBZL.AAB001; R_SIC81.AAC001 := V_RYJBZL.AAC001; R_SIC81.AAE140 := PI_AAE140; R_SIC81.CAE246 := ‘1‘; INSERT INTO SIC81 VALUES R_SIC81; END IF; PO_FHZ := ‘1‘; PO_MSG := V_MSG; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ylgrzh_cxtj‘; PO_MSG := ‘pkg_zhgl.ylgrzh_cxtj,传入参数:pi_aac001:‘ || PI_AAC001 || ‘pi_aae140:‘ || PI_AAE140 || ‘;系统错误信息是:‘ || SQLERRM; RETURN; END YLGRZH_CXTJ; PROCEDURE YLGRZH_GRNDJX_YB(PI_AAC001 AC01.AAC001%TYPE, PI_AAE140 IN VARCHAR2, PI_JXKSND IN VARCHAR2, ---计息开始年度 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS ----养老账户年度计息(从最近一次没有计息的年度开始)a 2013.5.24 /* 2013.8.13 由于征收的利息存在晚收的情况,经与a局讨论,征收的利息不与个人账户关联, 所有补缴的利息通过账户重新统计进行利息的计算,收取的征收利息和账户产生的利息单算。 2013.9.29 a 获取缴费信息时,不用从费款所属期获取,而是从缴费年月获取 --增加字段 AIC042【截止上年末累计缴费月数】、CIC818【本年实缴月数】、CIC819【本年缴费基数和】的记载 a 2013.10.05 增加失地农民一次性缴费的计息 a 2013.10.12 由于老系统中转移的账户每年都记录了,所以只有转移的最后一年才能开始计息(先不考虑多地转入的情况) a 2013.10.14 在1993年至1995年有很多人只有本地参保历史但却没有实缴记录,其年度缴费基数和月数通过历史统计 a 2013.12.04 账户计息,按本地、转移、一次性单独处理计息,这样可能要好处理一点,只是在最后的一年,处理SIC81 转移的只从最后转移的那年开始计息, a 2013.12.27 一次性缴费需确定缴费到账日期,用于记录当年的记账利息 a 2014.3.19 重新统计实际缴费月数 a 2014.4.11 养老退休一次性趸交与失地农民一次性趸交的相同 a 2014.9.4 将一次性趸缴的统一处理 a 2014.9.25 若计息月份为负数(因系统有到账日期的年度比账户年度大的情况)---此类只存在于一次性趸交的导入的情况 a 2014.10.10 统计缴费月数时,调整性补收的不算 */ V_GRJNYE NUMBER(10, 2); V_DWHRYE NUMBER(10, 2); V_GRLJ NUMBER(10, 2); V_ZHLJ NUMBER(10, 2); V_ZHRQ NUMBER(6); V_MINNF NUMBER(4); V_MINNF1 NUMBER(4); --转移年度年份 N_JZQJFLS NUMBER; N_JZQJFJE NUMBER(10, 2); N_JFNF NUMBER; N_GRJFJE NUMBER(10, 2); N_HRZHJE NUMBER(10, 2); N_DQLL NUMBER(4, 4); N_HQLL NUMBER(4, 4); R_ZH_ND SIC86%ROWTYPE; R_ZH_ZR SIC86%ROWTYPE; R_ZH_YCX SIC86%ROWTYPE; R_SIC81 SIC81%ROWTYPE; N_SHNF NUMBER(4); V_LJHRLX NUMBER(10, 2); V_LJJNLX NUMBER(10, 2); V_DWJS NUMBER(16, 2); --单位划入部分月积数 V_GRJS NUMBER(16, 2); --个人缴费部分月积数 V_ZR_COUNT NUMBER; V_LS_COUNT NUMBER; V_MSG VARCHAR2(1000); V_COUNT NUMBER; V_RYJBZL PKG_PUB.REC_RYJBZL; --个人基本资料 V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_grndjx_yb‘; V_PROCPARAMS VARCHAR2(3000); V_LXSR_GR NUMBER(12, 2); ---利息收入_个人缴纳 V_LXSR_HR NUMBER(12, 2); ---利息收入_单位划入 V_SIC83 SIC83%ROWTYPE; --账户变更明细表 V_AIC042_SN NUMBER(4); --截止上年末累计缴费月数_上年 V_CIC818_SN NUMBER(4); --本年实缴月数_上年 V_AIC042 NUMBER(4); --截止上年末累计缴费月数 V_CIC819 NUMBER(12, 2); --本年缴费基数和 V_CIC818 NUMBER(4); --本年实缴月数 V_YS NUMBER; V_ZHZY_JXKDND NUMBER(4); ---转移账户计息开始年度 V_ZHJXRQ NUMBER(8); V_CBYS NUMBER; ---转入的年度账户(可能会存在一年里有多个地方转入的情况) CURSOR C_NDZH(C_ZHND NUMBER) IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘ AND AAE001 = C_ZHND; ----获取失地农民一次性缴费所产生的账户 a 2013.10.05 ---获取养老退休一次性趸交 CURSOR C_NDZH_NMYCX(C_ZHND NUMBER) IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 NOT IN (‘0‘, ‘1‘) AND AAE001 = C_ZHND; BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxksnd=‘ || PI_JXKSND; IF PI_AAE140 NOT IN (‘110‘, ‘120‘) THEN PO_FHZ := ‘1‘; RETURN; END IF; V_ZR_COUNT := 0; V_MINNF := 0; V_MINNF1 := 0; --查询当前个人基本信息 PKG_BXGX_SHARE.GET_RYJBZL(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_MSG := ‘‘; ---删除计息年度及以后的非转入的年度缴费资料 DELETE SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND NVL(AAE087, ‘0‘) = ‘0‘ AND AAE001 >= PI_JXKSND; ---判断是否有转入的年度账户 SELECT COUNT(1) INTO V_LS_COUNT FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘; --查询转移的年度帐户 --如果有转入的年度账户,则获取最近的转入年度 IF V_LS_COUNT > 0 THEN SELECT MAX(AAE001) INTO V_MINNF1 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘; --查询转移的年度帐户 V_ZHZY_JXKDND := V_MINNF1; ----防止一年中有多条转入记录的情况 a 2013.11.26 SELECT MAX(NVL(AIC081, 0)) INTO V_ZHJXRQ FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘ AND AAE001 = V_ZHZY_JXKDND; END IF; SELECT TO_CHAR(SYSDATE, ‘YYYY‘) INTO N_SHNF FROM DUAL; R_ZH_ND.AAC001 := PI_AAC001; R_ZH_ND.AAE140 := PI_AAE140; R_ZH_ND.BAE001 := V_RYJBZL.BAE001; R_ZH_ND.AAB001 := V_RYJBZL.AAB001; R_ZH_ND.AAE087 := ‘0‘; R_ZH_ND.AAE035 := 0; R_ZH_ND.AIC081 := TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmdd‘)); V_MINNF := PI_JXKSND; IF V_MINNF < 1990 THEN V_MINNF := 1990; END IF; FOR N_JFNF IN V_MINNF .. N_SHNF LOOP V_LXSR_GR := 0; V_LXSR_HR := 0; ---由于这里不是账户重新统计,所以缴费的利息也需要进入计息 --取消征收时的利息 20130813 + NVL(SUM(AAC126) + NVL(SUM(AAC124) SELECT NVL(SUM(AAC123), 0), NVL(SUM(AAC125), 0), --- count(distinct cae121), NVL(SUM(DECODE(AAA115, ‘34‘, 0, ‘35‘, 0, ‘39‘, 0, ‘106‘, 0, 1)), 0), NVL(SUM(AAE180), 0) INTO N_GRJFJE, N_HRZHJE, V_CIC818, V_CIC819 FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND BCE094 = ‘1‘ AND SUBSTR(CAE121, 1, 4) = N_JFNF ---取审核年月的年度 20130606 取缴费年月 20130929 AND AAA115 NOT IN (‘90‘, ‘91‘, ‘40‘, ‘41‘); ---不含转入生成的实缴记录 R_ZH_ND.AAE001 := N_JFNF; R_ZH_ND.AIC058 := N_HRZHJE; R_ZH_ND.AIC072 := N_GRJFJE; ------设置本年实缴月数、本年缴费基数和 1990~1991 从历史中获取 a 2013.10.12 IF N_JFNF IN (1990, 1991) THEN IF N_JFNF IN (1990, 1991) THEN V_CIC818 := 0; END IF; SELECT SUM((MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) * AAE180) INTO V_CIC819 FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(AAE041, 1, 4) = N_JFNF; END IF; ---在1992年至1995年有很多人只有本地参保历史但却没有实缴记录,其年度缴费基数和月数通过历史统计 IF N_JFNF IN (1992, 1993, 1994, 1995) THEN SELECT SUM((MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) * AAE180), SUM(MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) INTO V_CIC819, V_CIC818 FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(AAE041, 1, 4) = N_JFNF; IF N_JFNF = 1992 THEN IF V_CIC818 > 9 THEN V_CIC818 := 9; END IF; END IF; END IF; ------设置本年实缴月数、本年缴费基数和 R_ZH_ND.CIC818 := V_CIC818; R_ZH_ND.CIC819 := V_CIC819; --取利率 ---企业养老从1996年1月开始计息,本市采用月积数法,所以只获取年记账年利率 ----如果是机关事业养老,则从2003年1月开始计算利息 IF (PI_AAE140 = ‘120‘ AND N_JFNF < 2003) OR (PI_AAE140 = ‘110‘ AND N_JFNF < 1996) THEN N_HQLL := 0; N_DQLL := 0; ELSE BEGIN ---获取年记账利率 SELECT AAA031 / 100 INTO N_DQLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = N_JFNF || ‘0101‘ AND AAE031 = N_JFNF || ‘1231‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := N_JFNF || ‘年度记帐利率参数缺少,请设置!‘; RETURN; END; END IF; IF N_SHNF = N_JFNF THEN --当年不计任何利息 R_ZH_ND.AIC074 := 0; R_ZH_ND.AIC075 := 0; R_ZH_ND.AIC076 := 0; R_ZH_ND.AIC077 := 0; R_ZH_ND.AIC081 := NULL; ---当年不计息时,计息日期也不用填写 ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC079), 0) INTO R_ZH_ND.AIC041 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); --个人缴纳累计金额(本金和利息)=历年个人本金+历年个人利息+本年个人本金+本年个人利息 R_ZH_ND.AIC079 := R_ZH_ND.AIC041 + R_ZH_ND.AIC076 + R_ZH_ND.AIC075 + R_ZH_ND.AIC072; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息、历年单位划入 (含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC078), 0) INTO R_ZH_ND.AIC040 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); ---获取上年度的累计缴费月数和当年缴费月数,计入本年度的累计缴费月数 (a 2013.09.28) SELECT NVL(SUM(AIC042), 0), NVL(SUM(CIC818), 0) INTO V_AIC042_SN, V_CIC818_SN FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); --and AAE087 = ‘0‘; ---截止上年末累计缴费月数 R_ZH_ND.AIC042 := V_AIC042_SN + V_CIC818_SN; R_ZH_ND.AIC078 := R_ZH_ND.AIC040 + R_ZH_ND.AIC077 + R_ZH_ND.AIC058 + R_ZH_ND.AIC074; ELSE --处理本年度非转入利息 --获取审核年度的利息积数 + nvl(aac124, 0) + nvl(aac126, 0) SELECT NVL(SUM((NVL(AAC123, 0)) * (N_JFNF || ‘12‘ - CAE121 + 1)), 0), NVL(SUM((NVL(AAC125, 0)) * (N_JFNF || ‘12‘ - CAE121 + 1)), 0) INTO V_GRJS, V_DWJS FROM SIC84 WHERE AAC001 = PI_AAC001 AND CAE121 BETWEEN N_JFNF || ‘01‘ AND N_JFNF || ‘12‘ AND AAE140 = PI_AAE140 AND AAA115 NOT IN (‘90‘, ‘91‘, ‘40‘, ‘41‘); ---不含转入生成的实缴记录 ---记账利率*当年利息积数/12 () R_ZH_ND.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_ND.AIC074 := N_DQLL * V_DWJS / 12; --本年缴费划入利息 V_LXSR_GR := V_LXSR_GR + R_ZH_ND.AIC075; V_LXSR_HR := V_LXSR_HR + R_ZH_ND.AIC074; ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC079), 0) * N_DQLL, NVL(SUM(AIC079), 0) INTO R_ZH_ND.AIC076, R_ZH_ND.AIC041 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); V_LXSR_GR := V_LXSR_GR + R_ZH_ND.AIC076; --个人缴纳累计金额(本金和利息)=历年个人本金+历年个人利息+本年个人本金+本年个人利息 R_ZH_ND.AIC079 := R_ZH_ND.AIC041 + R_ZH_ND.AIC076 + R_ZH_ND.AIC075 + R_ZH_ND.AIC072; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息、历年单位划入 (含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC078), 0) * N_DQLL, NVL(SUM(AIC078), 0) INTO R_ZH_ND.AIC077, R_ZH_ND.AIC040 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); V_LXSR_HR := V_LXSR_HR + R_ZH_ND.AIC077; R_ZH_ND.AIC078 := R_ZH_ND.AIC040 + R_ZH_ND.AIC077 + R_ZH_ND.AIC058 + R_ZH_ND.AIC074; ---获取上年度的累计缴费月数和当年缴费月数,计入本年度的累计缴费月数 (a 2013.09.28) SELECT NVL(SUM(AIC042), 0), NVL(SUM(CIC818), 0) INTO V_AIC042_SN, V_CIC818_SN FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); -- and AAE087 = ‘0‘; ---截止上年末累计缴费月数 R_ZH_ND.AIC042 := V_AIC042_SN + V_CIC818_SN; --处理本年度的转入帐户利息--只计转入年度的利息,之前的不计,之所以用循环,是考虑同时从多地转入 IF N_JFNF = V_ZHZY_JXKDND AND V_ZHJXRQ = 0 THEN FOR V_NDZH_ZR IN C_NDZH(N_JFNF) LOOP SELECT * INTO R_ZH_ZR FROM SIC86 WHERE AAC001 = V_NDZH_ZR.AAC001 AND AAE140 = V_NDZH_ZR.AAE140 AND AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; V_YS := N_JFNF || 12 - SUBSTR(R_ZH_ZR.AAE035, 1, 6) + 1; V_GRJS := NVL(R_ZH_ZR.AIC072, 0) * V_YS; V_DWJS := NVL(R_ZH_ZR.AIC058, 0) * V_YS; R_ZH_ZR.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_ZR.AIC074 := N_DQLL * V_DWJS / 12; V_LXSR_GR := V_LXSR_GR + R_ZH_ZR.AIC075; V_LXSR_HR := V_LXSR_HR + R_ZH_ZR.AIC074; UPDATE SIC86 SET AIC075 = R_ZH_ZR.AIC075, AIC074 = R_ZH_ZR.AIC074, AIC078 = R_ZH_ZR.AIC074 + R_ZH_ZR.AIC058, AIC079 = R_ZH_ZR.AIC075 + R_ZH_ZR.AIC072 WHERE AAC001 = V_NDZH_ZR.AAC001 AND AAE140 = V_NDZH_ZR.AAE140 AND AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; --end 处理非本年度的转入(市外转入或者险种转移)帐户利息 END LOOP; END IF; --处理本年度的失地农民的一次性缴费帐户利息 a2013.10.05 --增加养老退休一次性缴费 a 2014.4.14 FOR V_NDZH_YCX IN C_NDZH_NMYCX(N_JFNF) LOOP SELECT * INTO R_ZH_YCX FROM SIC86 WHERE AAC001 = V_NDZH_YCX.AAC001 AND AAE140 = V_NDZH_YCX.AAE140 AND AAE001 = V_NDZH_YCX.AAE001 AND AAE087 = V_NDZH_YCX.AAE087 AND AAE035 = V_NDZH_YCX.AAE035; ---确定一次性缴费的到账日期 a 2013.12.27 IF NVL(R_ZH_YCX.AAE035, 0) = 0 THEN V_YS := 0; ELSE V_YS := N_JFNF || 12 - SUBSTR(R_ZH_YCX.AAE035, 1, 6) + 1; IF V_YS > 12 THEN V_YS := 12; END IF; ---a 2014.9.25 计息月数小于0,则以0计 IF V_YS < 0 THEN V_YS := 0; END IF; END IF; --- v_ys := n_jfnf||12 - substr(r_zh_ycx.AAE035,1,6) + 1; V_GRJS := NVL(R_ZH_YCX.AIC072, 0) * V_YS; V_DWJS := NVL(R_ZH_YCX.AIC058, 0) * V_YS; R_ZH_YCX.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_YCX.AIC074 := N_DQLL * V_DWJS / 12; UPDATE SIC86 SET AIC075 = R_ZH_YCX.AIC075, AIC074 = R_ZH_YCX.AIC074, AIC078 = NVL(R_ZH_YCX.AIC074, 0) + NVL(R_ZH_YCX.AIC058, 0), AIC079 = NVL(R_ZH_YCX.AIC075, 0) + NVL(R_ZH_YCX.AIC072, 0) WHERE AAC001 = V_NDZH_YCX.AAC001 AND AAE140 = V_NDZH_YCX.AAE140 AND AAE001 = V_NDZH_YCX.AAE001 AND AAE087 = V_NDZH_YCX.AAE087 AND AAE035 = V_NDZH_YCX.AAE035; END LOOP; END IF; INSERT INTO SIC86 VALUES R_ZH_ND; ---记录计息年度的利息收入--这里不能调用下面的利息生成,会对已经产生的利息重算 --直接写入 sic83 IF (V_LXSR_GR + V_LXSR_HR) > 0 THEN SELECT SEQ_BXGX_CAE176.NEXTVAL INTO V_SIC83.CAE176 FROM DUAL; V_SIC83.CAE177 := ‘4‘; V_SIC83.BAE001 := V_RYJBZL.BAE001; V_SIC83.AAB001 := V_RYJBZL.AAB001; V_SIC83.AAC001 := V_RYJBZL.AAC001; V_SIC83.AAE140 := PI_AAE140; V_SIC83.CAE178 := ‘1‘; V_SIC83.CAE230 := ‘22‘; V_SIC83.AAC124 := V_LXSR_GR; V_SIC83.AAC126 := V_LXSR_HR; V_SIC83.CAE233 := PKG_FUN.F_GET_SYSDATE(14); -- 帐户写入时间 V_SIC83.CAE683 := N_JFNF || ‘1231‘; -- 财务确认时间 V_SIC83.CAE124 := N_JFNF || ‘1231‘; INSERT INTO SIC83 VALUES V_SIC83; END IF; END LOOP; ---计息完毕后,最后一年的年度账户即为参保人员的当前账户 ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC058), 0) BNBJDW, NVL(SUM(AIC072), 0) BNBJGR, NVL(SUM(AIC074), 0) BNDWLX, NVL(SUM(AIC075), 0) BNGRLX, NVL(SUM(AIC078), 0) DWHRYE, NVL(SUM(AIC079), 0) GRJNYE, NVL(SUM(AIC076), 0) GRLNLX, NVL(SUM(AIC077), 0) DWLNLX, NVL(SUM(AIC040), 0), NVL(SUM(AIC041), 0) INTO R_SIC81.AAE262, R_SIC81.AAE264, R_SIC81.AAE263, R_SIC81.AAE265, R_SIC81.CAC046, R_SIC81.CAC047, R_SIC81.AAE257, R_SIC81.AAE256, R_SIC81.AAE253, R_SIC81.AAE254 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE001 = N_SHNF AND AAE140 = PI_AAE140; ---历年账户(只去本地业务产生-仅有一条) /* select nvl(aic040, 0), nvl(aic041, 0) into r_sic81.AAE253, r_sic81.AAE254 from sic86 where aac001 = pi_aac001 and aae001 = n_shnf and aae140 = pi_aae140 and AaE087 = ‘0‘; */ ---重新统计实际缴费月数--a 2014.3.19 SELECT COUNT(DISTINCT CAE121) INTO V_CBYS FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = ‘110‘ AND AAA115 IN (‘10‘, ‘101‘, ‘103‘, ‘104‘, ‘105‘, ‘120‘, ‘31‘, ‘90‘, ‘91‘, ‘110‘) AND CAE121 > 199203; UPDATE AC02 SET AAE201 = V_CBYS WHERE AAE140 = ‘110‘ AND AAC001 = PI_AAC001; UPDATE SIC81 SET AAE262 = R_SIC81.AAE262, AAE264 = R_SIC81.AAE264, AAE263 = R_SIC81.AAE263, AAE265 = R_SIC81.AAE265, CAC046 = R_SIC81.CAC046, CAC047 = R_SIC81.CAC047, AAE253 = R_SIC81.AAE253, AAE254 = R_SIC81.AAE254, AAE257 = R_SIC81.AAE257, AAE256 = R_SIC81.AAE256 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; IF SQL%NOTFOUND THEN R_SIC81.BAE001 := V_RYJBZL.BAE001; R_SIC81.AAB001 := V_RYJBZL.AAB001; R_SIC81.AAC001 := V_RYJBZL.AAC001; R_SIC81.AAE140 := PI_AAE140; R_SIC81.CAE246 := ‘1‘; INSERT INTO SIC81 VALUES R_SIC81; END IF; PO_FHZ := ‘1‘; PO_MSG := V_MSG; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ylgrzh_grndjx_yb‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END YLGRZH_GRNDJX_YB; PROCEDURE YLGRZH_GRNDJX_YB_NEXT(PI_AAC001 AC01.AAC001%TYPE, PI_AAE140 IN VARCHAR2, PI_JXKSND IN VARCHAR2, ---计息开始年度 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS ----养老账户--年度结息-结转到下一年度(从最近一次没有计息的年度开始)a 2014.12.28 /* 2013.8.13 由于征收的利息存在晚收的情况,经与a局讨论,征收的利息不与个人账户关联, 所有补缴的利息通过账户重新统计进行利息的计算,收取的征收利息和账户产生的利息单算。 2013.9.29 a 获取缴费信息时,不用从费款所属期获取,而是从缴费年月获取 --增加字段 AIC042【截止上年末累计缴费月数】、CIC818【本年实缴月数】、CIC819【本年缴费基数和】的记载 a 2013.10.05 增加失地农民一次性缴费的计息 a 2013.10.12 由于老系统中转移的账户每年都记录了,所以只有转移的最后一年才能开始计息(先不考虑多地转入的情况) a 2013.10.14 在1993年至1995年有很多人只有本地参保历史但却没有实缴记录,其年度缴费基数和月数通过历史统计 a 2013.12.04 账户计息,按本地、转移、一次性单独处理计息,这样可能要好处理一点,只是在最后的一年,处理SIC81 转移的只从最后转移的那年开始计息, a 2013.12.27 一次性缴费需确定缴费到账日期,用于记录当年的记账利息 a 2014.3.19 重新统计实际缴费月数 a 2014.4.11 养老退休一次性趸交与失地农民一次性趸交的相同 a 2014.9.4 将一次性趸缴的统一处理 a 2014.9.25 若计息月份为负数(因系统有到账日期的年度比账户年度大的情况)---此类只存在于一次性趸交的导入的情况 a 2014.10.10 统计缴费月数时,调整性补收的不算 */ V_GRJNYE NUMBER(10, 2); V_DWHRYE NUMBER(10, 2); V_GRLJ NUMBER(10, 2); V_ZHLJ NUMBER(10, 2); V_ZHRQ NUMBER(6); V_MINNF NUMBER(4); V_MINNF1 NUMBER(4); --转移年度年份 N_JZQJFLS NUMBER; N_JZQJFJE NUMBER(10, 2); N_JFNF NUMBER; N_GRJFJE NUMBER(10, 2); N_HRZHJE NUMBER(10, 2); N_DQLL NUMBER(4, 4); N_HQLL NUMBER(4, 4); R_ZH_ND SIC86%ROWTYPE; R_ZH_ZR SIC86%ROWTYPE; R_ZH_YCX SIC86%ROWTYPE; R_SIC81 SIC81%ROWTYPE; N_SHNF NUMBER(4); V_LJHRLX NUMBER(10, 2); V_LJJNLX NUMBER(10, 2); V_DWJS NUMBER(16, 2); --单位划入部分月积数 V_GRJS NUMBER(16, 2); --个人缴费部分月积数 V_ZR_COUNT NUMBER; V_LS_COUNT NUMBER; V_MSG VARCHAR2(1000); V_COUNT NUMBER; V_RYJBZL PKG_PUB.REC_RYJBZL; --个人基本资料 V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘Ylgrzh_Grndjx_Yb_Next‘; V_PROCPARAMS VARCHAR2(3000); V_LXSR_GR NUMBER(12, 2); ---利息收入_个人缴纳 V_LXSR_HR NUMBER(12, 2); ---利息收入_单位划入 V_SIC83 SIC83%ROWTYPE; --账户变更明细表 V_AIC042_SN NUMBER(4); --截止上年末累计缴费月数_上年 V_CIC818_SN NUMBER(4); --本年实缴月数_上年 V_AIC042 NUMBER(4); --截止上年末累计缴费月数 V_CIC819 NUMBER(12, 2); --本年缴费基数和 V_CIC818 NUMBER(4); --本年实缴月数 V_YS NUMBER; V_ZHZY_JXKDND NUMBER(4); ---转移账户计息开始年度 V_ZHJXRQ NUMBER(8); V_CBYS NUMBER; ---转入的年度账户(可能会存在一年里有多个地方转入的情况) CURSOR C_NDZH(C_ZHND NUMBER) IS SELECT * FROM TEMP_SIC86_NDJX WHERE AAE087 = ‘1‘ AND AAE001 = C_ZHND; ----获取失地农民一次性缴费所产生的账户 a 2013.10.05 ---获取养老退休一次性趸交 CURSOR C_NDZH_NMYCX(C_ZHND NUMBER) IS SELECT * FROM TEMP_SIC86_NDJX WHERE AAE087 NOT IN (‘0‘, ‘1‘) AND AAE001 = C_ZHND; BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxksnd=‘ || PI_JXKSND; --生成临时表数据以备使用 INSERT INTO TEMP_SIC86_NDJX SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; IF PI_AAE140 NOT IN (‘110‘, ‘120‘) THEN PO_FHZ := ‘1‘; RETURN; END IF; V_ZR_COUNT := 0; V_MINNF := 0; V_MINNF1 := 0; --查询当前个人基本信息 PKG_BXGX_SHARE.GET_RYJBZL(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_MSG := ‘‘; ---删除计息年度及以后的非转入的年度缴费资料 DELETE TEMP_SIC86_NDJX WHERE NVL(AAE087, ‘0‘) = ‘0‘ AND AAE001 >= PI_JXKSND; ---判断是否有转入的年度账户 SELECT COUNT(1) INTO V_LS_COUNT FROM TEMP_SIC86_NDJX WHERE AAE087 = ‘1‘; --查询转移的年度帐户 --如果有转入的年度账户,则获取最近的转入年度 IF V_LS_COUNT > 0 THEN SELECT MAX(AAE001) INTO V_MINNF1 FROM TEMP_SIC86_NDJX WHERE AAE087 = ‘1‘; --查询转移的年度帐户 V_ZHZY_JXKDND := V_MINNF1; ----防止一年中有多条转入记录的情况 a 2013.11.26 SELECT MAX(NVL(AIC081, 0)) INTO V_ZHJXRQ FROM TEMP_SIC86_NDJX WHERE AAE087 = ‘1‘ AND AAE001 = V_ZHZY_JXKDND; END IF; SELECT TO_CHAR(SYSDATE, ‘YYYY‘) + 1 INTO N_SHNF FROM DUAL; R_ZH_ND.AAC001 := PI_AAC001; R_ZH_ND.AAE140 := PI_AAE140; R_ZH_ND.BAE001 := V_RYJBZL.BAE001; R_ZH_ND.AAB001 := V_RYJBZL.AAB001; R_ZH_ND.AAE087 := ‘0‘; R_ZH_ND.AAE035 := 0; R_ZH_ND.AIC081 := TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmdd‘)); V_MINNF := PI_JXKSND; IF V_MINNF < 1990 THEN V_MINNF := 1990; END IF; FOR N_JFNF IN V_MINNF .. N_SHNF LOOP V_LXSR_GR := 0; V_LXSR_HR := 0; ---由于这里不是账户重新统计,所以缴费的利息也需要进入计息 --取消征收时的利息 20130813 + NVL(SUM(AAC126) + NVL(SUM(AAC124) SELECT NVL(SUM(AAC123), 0), NVL(SUM(AAC125), 0), --- count(distinct cae121), NVL(SUM(DECODE(AAA115, ‘34‘, 0, ‘35‘, 0, ‘39‘, 0, ‘106‘, 0, 1)), 0), NVL(SUM(AAE180), 0) INTO N_GRJFJE, N_HRZHJE, V_CIC818, V_CIC819 FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND BCE094 = ‘1‘ AND SUBSTR(CAE121, 1, 4) = N_JFNF ---取审核年月的年度 20130606 取缴费年月 20130929 AND AAA115 NOT IN (‘90‘, ‘91‘, ‘40‘, ‘41‘); ---不含转入生成的实缴记录 R_ZH_ND.AAE001 := N_JFNF; R_ZH_ND.AIC058 := N_HRZHJE; R_ZH_ND.AIC072 := N_GRJFJE; ------设置本年实缴月数、本年缴费基数和 1990~1991 从历史中获取 a 2013.10.12 IF N_JFNF IN (1990, 1991) THEN IF N_JFNF IN (1990, 1991) THEN V_CIC818 := 0; END IF; SELECT SUM((MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) * AAE180) INTO V_CIC819 FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(AAE041, 1, 4) = N_JFNF; END IF; ---在1992年至1995年有很多人只有本地参保历史但却没有实缴记录,其年度缴费基数和月数通过历史统计 IF N_JFNF IN (1992, 1993, 1994, 1995) THEN SELECT SUM((MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) * AAE180), SUM(MONTHS_BETWEEN(TO_DATE(AAE042, ‘yyyymm‘), TO_DATE(AAE041, ‘yyyymm‘)) + 1) INTO V_CIC819, V_CIC818 FROM AC20 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(AAE041, 1, 4) = N_JFNF; IF N_JFNF = 1992 THEN IF V_CIC818 > 9 THEN V_CIC818 := 9; END IF; END IF; END IF; ------设置本年实缴月数、本年缴费基数和 R_ZH_ND.CIC818 := V_CIC818; R_ZH_ND.CIC819 := V_CIC819; --取利率 ---企业养老从1996年1月开始计息,本市采用月积数法,所以只获取年记账年利率 ----如果是机关事业养老,则从2003年1月开始计算利息 IF (PI_AAE140 = ‘120‘ AND N_JFNF < 2003) OR (PI_AAE140 = ‘110‘ AND N_JFNF < 1996) THEN N_HQLL := 0; N_DQLL := 0; ELSE BEGIN ---获取年记账利率 SELECT AAA031 / 100 INTO N_DQLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = N_JFNF || ‘0101‘ AND AAE031 = N_JFNF || ‘1231‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := N_JFNF || ‘年度记帐利率参数缺少,请设置!‘; RETURN; END; END IF; IF N_SHNF = N_JFNF THEN --当年不计任何利息 R_ZH_ND.AIC074 := 0; R_ZH_ND.AIC075 := 0; R_ZH_ND.AIC076 := 0; R_ZH_ND.AIC077 := 0; R_ZH_ND.AIC081 := NULL; ---当年不计息时,计息日期也不用填写 ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC079), 0) INTO R_ZH_ND.AIC041 FROM TEMP_SIC86_NDJX WHERE ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); --个人缴纳累计金额(本金和利息)=历年个人本金+历年个人利息+本年个人本金+本年个人利息 R_ZH_ND.AIC079 := R_ZH_ND.AIC041 + R_ZH_ND.AIC076 + R_ZH_ND.AIC075 + R_ZH_ND.AIC072; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息、历年单位划入 (含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC078), 0) INTO R_ZH_ND.AIC040 FROM TEMP_SIC86_NDJX WHERE ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); ---获取上年度的累计缴费月数和当年缴费月数,计入本年度的累计缴费月数 (a 2013.09.28) SELECT NVL(SUM(AIC042), 0), NVL(SUM(CIC818), 0) INTO V_AIC042_SN, V_CIC818_SN FROM TEMP_SIC86_NDJX WHERE AAE001 = (N_JFNF - 1); --and AAE087 = ‘0‘; ---截止上年末累计缴费月数 R_ZH_ND.AIC042 := V_AIC042_SN + V_CIC818_SN; R_ZH_ND.AIC078 := R_ZH_ND.AIC040 + R_ZH_ND.AIC077 + R_ZH_ND.AIC058 + R_ZH_ND.AIC074; ELSE --处理本年度非转入利息 --获取审核年度的利息积数 + nvl(aac124, 0) + nvl(aac126, 0) SELECT NVL(SUM((NVL(AAC123, 0)) * (N_JFNF || ‘12‘ - CAE121 + 1)), 0), NVL(SUM((NVL(AAC125, 0)) * (N_JFNF || ‘12‘ - CAE121 + 1)), 0) INTO V_GRJS, V_DWJS FROM SIC84 WHERE AAC001 = PI_AAC001 AND CAE121 BETWEEN N_JFNF || ‘01‘ AND N_JFNF || ‘12‘ AND AAE140 = PI_AAE140 AND AAA115 NOT IN (‘90‘, ‘91‘, ‘40‘, ‘41‘); ---不含转入生成的实缴记录 ---记账利率*当年利息积数/12 () R_ZH_ND.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_ND.AIC074 := N_DQLL * V_DWJS / 12; --本年缴费划入利息 V_LXSR_GR := V_LXSR_GR + R_ZH_ND.AIC075; V_LXSR_HR := V_LXSR_HR + R_ZH_ND.AIC074; ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC079), 0) * N_DQLL, NVL(SUM(AIC079), 0) INTO R_ZH_ND.AIC076, R_ZH_ND.AIC041 FROM TEMP_SIC86_NDJX WHERE ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); V_LXSR_GR := V_LXSR_GR + R_ZH_ND.AIC076; --个人缴纳累计金额(本金和利息)=历年个人本金+历年个人利息+本年个人本金+本年个人利息 R_ZH_ND.AIC079 := R_ZH_ND.AIC041 + R_ZH_ND.AIC076 + R_ZH_ND.AIC075 + R_ZH_ND.AIC072; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息、历年单位划入 (含历年转入) -- 不含历年转入,只能含最后一年的转入 a 2013.12.04 SELECT NVL(SUM(AIC078), 0) * N_DQLL, NVL(SUM(AIC078), 0) INTO R_ZH_ND.AIC077, R_ZH_ND.AIC040 FROM TEMP_SIC86_NDJX WHERE ((AAE001 = N_JFNF - 1 AND AAE087 <> ‘1‘) OR (AAE001 = N_JFNF - 1 AND V_ZHZY_JXKDND = N_JFNF - 1 AND AAE087 = ‘1‘)); V_LXSR_HR := V_LXSR_HR + R_ZH_ND.AIC077; R_ZH_ND.AIC078 := R_ZH_ND.AIC040 + R_ZH_ND.AIC077 + R_ZH_ND.AIC058 + R_ZH_ND.AIC074; ---获取上年度的累计缴费月数和当年缴费月数,计入本年度的累计缴费月数 (a 2013.09.28) SELECT NVL(SUM(AIC042), 0), NVL(SUM(CIC818), 0) INTO V_AIC042_SN, V_CIC818_SN FROM TEMP_SIC86_NDJX WHERE AAE001 = (N_JFNF - 1); -- and AAE087 = ‘0‘; ---截止上年末累计缴费月数 R_ZH_ND.AIC042 := V_AIC042_SN + V_CIC818_SN; --处理本年度的转入帐户利息--只计转入年度的利息,之前的不计,之所以用循环,是考虑同时从多地转入 IF N_JFNF = V_ZHZY_JXKDND AND V_ZHJXRQ = 0 THEN FOR V_NDZH_ZR IN C_NDZH(N_JFNF) LOOP SELECT * INTO R_ZH_ZR FROM TEMP_SIC86_NDJX WHERE AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; V_YS := N_JFNF || 12 - SUBSTR(R_ZH_ZR.AAE035, 1, 6) + 1; V_GRJS := NVL(R_ZH_ZR.AIC072, 0) * V_YS; V_DWJS := NVL(R_ZH_ZR.AIC058, 0) * V_YS; R_ZH_ZR.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_ZR.AIC074 := N_DQLL * V_DWJS / 12; V_LXSR_GR := V_LXSR_GR + R_ZH_ZR.AIC075; V_LXSR_HR := V_LXSR_HR + R_ZH_ZR.AIC074; UPDATE TEMP_SIC86_NDJX SET AIC075 = R_ZH_ZR.AIC075, AIC074 = R_ZH_ZR.AIC074, AIC078 = R_ZH_ZR.AIC074 + R_ZH_ZR.AIC058, AIC079 = R_ZH_ZR.AIC075 + R_ZH_ZR.AIC072 WHERE AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; --end 处理非本年度的转入(市外转入或者险种转移)帐户利息 END LOOP; END IF; --处理本年度的失地农民的一次性缴费帐户利息 a2013.10.05 --增加养老退休一次性缴费 a 2014.4.14 FOR V_NDZH_YCX IN C_NDZH_NMYCX(N_JFNF) LOOP SELECT * INTO R_ZH_YCX FROM TEMP_SIC86_NDJX WHERE AAE001 = V_NDZH_YCX.AAE001 AND AAE087 = V_NDZH_YCX.AAE087 AND AAE035 = V_NDZH_YCX.AAE035; ---确定一次性缴费的到账日期 a 2013.12.27 IF NVL(R_ZH_YCX.AAE035, 0) = 0 THEN V_YS := 0; ELSE V_YS := N_JFNF || 12 - SUBSTR(R_ZH_YCX.AAE035, 1, 6) + 1; IF V_YS > 12 THEN V_YS := 12; END IF; ---a 2014.9.25 计息月数小于0,则以0计 IF V_YS < 0 THEN V_YS := 0; END IF; END IF; --- v_ys := n_jfnf||12 - substr(r_zh_ycx.AAE035,1,6) + 1; V_GRJS := NVL(R_ZH_YCX.AIC072, 0) * V_YS; V_DWJS := NVL(R_ZH_YCX.AIC058, 0) * V_YS; R_ZH_YCX.AIC075 := N_DQLL * V_GRJS / 12; --本年缴费个人利息 R_ZH_YCX.AIC074 := N_DQLL * V_DWJS / 12; UPDATE TEMP_SIC86_NDJX SET AIC075 = R_ZH_YCX.AIC075, AIC074 = R_ZH_YCX.AIC074, AIC078 = NVL(R_ZH_YCX.AIC074, 0) + NVL(R_ZH_YCX.AIC058, 0), AIC079 = NVL(R_ZH_YCX.AIC075, 0) + NVL(R_ZH_YCX.AIC072, 0) WHERE AAE001 = V_NDZH_YCX.AAE001 AND AAE087 = V_NDZH_YCX.AAE087 AND AAE035 = V_NDZH_YCX.AAE035; END LOOP; END IF; INSERT INTO TEMP_SIC86_NDJX VALUES R_ZH_ND; ---记录计息年度的利息收入--这里不能调用下面的利息生成,会对已经产生的利息重算 --直接写入 sic83 IF (V_LXSR_GR + V_LXSR_HR) > 0 THEN SELECT SEQ_BXGX_CAE176.NEXTVAL INTO V_SIC83.CAE176 FROM DUAL; V_SIC83.CAE177 := ‘4‘; V_SIC83.BAE001 := V_RYJBZL.BAE001; V_SIC83.AAB001 := V_RYJBZL.AAB001; V_SIC83.AAC001 := V_RYJBZL.AAC001; V_SIC83.AAE140 := PI_AAE140; V_SIC83.CAE178 := ‘1‘; V_SIC83.CAE230 := ‘22‘; V_SIC83.AAC124 := V_LXSR_GR; V_SIC83.AAC126 := V_LXSR_HR; V_SIC83.CAE233 := PKG_FUN.F_GET_SYSDATE(14); -- 帐户写入时间 V_SIC83.CAE683 := N_JFNF || ‘1231‘; -- 财务确认时间 V_SIC83.CAE124 := N_JFNF || ‘1231‘; INSERT INTO SIC83 VALUES V_SIC83; END IF; END LOOP; ---计息完毕后,最后一年的年度账户即为参保人员的当前账户 ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC058), 0) BNBJDW, NVL(SUM(AIC072), 0) BNBJGR, NVL(SUM(AIC074), 0) BNDWLX, NVL(SUM(AIC075), 0) BNGRLX, NVL(SUM(AIC078), 0) DWHRYE, NVL(SUM(AIC079), 0) GRJNYE, NVL(SUM(AIC076), 0) GRLNLX, NVL(SUM(AIC077), 0) DWLNLX, NVL(SUM(AIC040), 0), NVL(SUM(AIC041), 0) INTO R_SIC81.AAE262, R_SIC81.AAE264, R_SIC81.AAE263, R_SIC81.AAE265, R_SIC81.CAC046, R_SIC81.CAC047, R_SIC81.AAE257, R_SIC81.AAE256, R_SIC81.AAE253, R_SIC81.AAE254 FROM TEMP_SIC86_NDJX WHERE AAE001 = N_SHNF; ---历年账户(只去本地业务产生-仅有一条) /* select nvl(aic040, 0), nvl(aic041, 0) into r_sic81.AAE253, r_sic81.AAE254 from sic86 where aac001 = pi_aac001 and aae001 = n_shnf and aae140 = pi_aae140 and AaE087 = ‘0‘; */ ---重新统计实际缴费月数--a 2014.3.19 SELECT COUNT(DISTINCT CAE121) INTO V_CBYS FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = ‘110‘ AND AAA115 IN (‘10‘, ‘101‘, ‘103‘, ‘104‘, ‘105‘, ‘120‘, ‘31‘, ‘90‘, ‘91‘, ‘110‘) AND CAE121 > 199203; UPDATE AC02 SET AAE201 = V_CBYS WHERE AAE140 = ‘110‘ AND AAC001 = PI_AAC001; UPDATE SIC81 SET AAE262 = R_SIC81.AAE262, AAE264 = R_SIC81.AAE264, AAE263 = R_SIC81.AAE263, AAE265 = R_SIC81.AAE265, CAC046 = R_SIC81.CAC046, CAC047 = R_SIC81.CAC047, AAE253 = R_SIC81.AAE253, AAE254 = R_SIC81.AAE254, AAE257 = R_SIC81.AAE257, AAE256 = R_SIC81.AAE256 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; IF SQL%NOTFOUND THEN R_SIC81.BAE001 := V_RYJBZL.BAE001; R_SIC81.AAB001 := V_RYJBZL.AAB001; R_SIC81.AAC001 := V_RYJBZL.AAC001; R_SIC81.AAE140 := PI_AAE140; R_SIC81.CAE246 := ‘1‘; INSERT INTO SIC81 VALUES R_SIC81; END IF; --临时表结果回写 DELETE FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; INSERT INTO SIC86 SELECT * FROM TEMP_SIC86_NDJX; PO_FHZ := ‘1‘; PO_MSG := V_MSG; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ylgrzh_grndjx_yb‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END YLGRZH_GRNDJX_YB_NEXT; PROCEDURE YLGRZH_GRNDJX_ADWJX(PI_AAE001 IN VARCHAR2, --计息年度 PI_BAE001 IN VARCHAR2, --系统机构 PI_AAE140 IN VARCHAR2, --险种 PI_AAB001 IN VARCHAR2, --单位编号 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS ---养老账户年度计息(按单位) a add by 2013.6.18 V_JXND NUMBER; V_CAE125 NUMBER; CURSOR C_GRJBZL IS ---获取需要计息的人员id SELECT AAC001 FROM SIC81 WHERE BAE001 = PI_BAE001 AND AAE140 = PI_AAE140 AND AAB001 = DECODE(PI_AAB001, 0, AAB001, PI_AAB001) AND CAE246 = ‘1‘ AND AAC001 IN (SELECT AAC001 FROM AC01 WHERE BAE001 = PI_BAE001); BEGIN V_JXND := PI_AAE001; ---如果输入的计息年度为当年的话,则将计息年度设为上一年度 IF PI_AAE001 = TO_CHAR(SYSDATE, ‘yyyy‘) THEN V_JXND := PI_AAE001 - 1; END IF; FOR V_GRJBZL IN C_GRJBZL LOOP YLGRZH_GRNDJX_YB(V_GRJBZL.AAC001, PI_AAE140, V_JXND, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; END LOOP; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘gtryjf_yhdk_99‘; PO_MSG := ‘错误代码:‘ || SQLERRM; RETURN; END YLGRZH_GRNDJX_ADWJX; --年度结息-结转到下一年度 PROCEDURE YLGRZH_GRNDJX_ADWJX_NEXT(PI_AAE001 IN VARCHAR2, --计息年度 PI_BAE001 IN VARCHAR2, --系统机构 PI_AAE140 IN VARCHAR2, --险种 PI_AAB001 IN VARCHAR2, --单位编号 PI_GRBH IN NUMBER, --开始个人编号 PO_AAC001 OUT NUMBER, PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS ---养老账户年度计息(按单位) a add by 2014.12.28 V_JXND NUMBER; V_CAE125 NUMBER; CURSOR C_GRJBZL IS ---获取需要计息的人员id SELECT AAC001 FROM SIC81 A WHERE BAE001 = PI_BAE001 AND AAE140 = PI_AAE140 AND AAB001 = DECODE(PI_AAB001, 0, AAB001, PI_AAB001) AND CAE246 = ‘1‘ AND AAC001 >= PI_GRBH AND EXISTS (SELECT 1 FROM AC01 WHERE BAE001 = PI_BAE001 AND AAC001 = A.AAC001) AND NOT EXISTS (SELECT 1 FROM IC10 WHERE AAC001 = A.AAC001) ORDER BY AAC001; BEGIN V_JXND := PI_AAE001; PO_FHZ := ‘1‘; ---如果输入的计息年度为当年的话,则将计息年度设为上一年度 IF PI_AAE001 < TO_CHAR(SYSDATE, ‘yyyy‘) THEN V_JXND := TO_CHAR(SYSDATE, ‘yyyy‘); END IF; FOR V_GRJBZL IN C_GRJBZL LOOP PO_AAC001 := V_GRJBZL.AAC001; YLGRZH_GRNDJX_YB_NEXT(V_GRJBZL.AAC001, PI_AAE140, V_JXND, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN ROLLBACK; RETURN; END IF; COMMIT; END LOOP; PO_AAC001 := 0; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘gtryjf_yhdk_99‘; PO_MSG := ‘错误代码:‘ || SQLERRM; RETURN; END YLGRZH_GRNDJX_ADWJX_NEXT; --养老账户年度结转 --全系统统一结转 --Add by a 2014.12.28 PROCEDURE YLGRZH_NDJZ_ALL(PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘Ylgrzh_Ndjz_All‘; V_PARAMS VARCHAR2(3000); V_BAE001 VARCHAR2(14); V_AAB001 NUMBER(20, 0); V_AAC001 NUMBER(20, 0); V_AAE001 NUMBER(4, 0); V_GRBH NUMBER(20, 0); V_FHZ VARCHAR2(400); V_MSG VARCHAR2(2000); V_CLBZ VARCHAR2(6); CURSOR C_ZL IS SELECT * FROM ICD1 WHERE CLBZ = ‘0‘ ORDER BY BAE001, AAB001; BEGIN V_PARAMS := ‘,传入参数为无‘; PO_FHZ := ‘1‘; FOR V_ZL IN C_ZL LOOP V_BAE001 := V_ZL.BAE001; V_AAB001 := V_ZL.AAB001; V_AAE001 := V_ZL.AAE001; V_GRBH := V_ZL.AAC001; YLGRZH_GRNDJX_ADWJX_NEXT(V_AAE001, V_BAE001, ‘110‘, V_AAB001, V_GRBH, V_AAC001, V_FHZ, V_MSG); IF V_FHZ != ‘1‘ THEN V_CLBZ := ‘-99‘; ELSE V_CLBZ := ‘1‘; V_MSG := ‘‘; END IF; UPDATE ICD1 SET CLBZ = V_CLBZ, AAC001 = V_AAC001, AAE013 = V_MSG, AAE036 = SYSDATE WHERE BAE001 = V_BAE001 AND AAB001 = V_AAB001 AND AAE001 = V_AAE001; COMMIT; END LOOP; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := V_PROCNAME || ‘_999‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PARAMS); RETURN; END YLGRZH_NDJZ_ALL; PROCEDURE YLGRZH_GRNZJX_YB(PI_AAC001 AC01.AAC001%TYPE, PI_AAE140 IN VARCHAR2, PI_JXZZNY IN VARCHAR2, ---计息终止年月(退休计息的输入为退休年月,其他则为系统年月) PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS ----养老账户年中计息(从没有计息的最小年度开始)a 2013.6.20 /* 2013.8.13 由于征收的利息存在晚收的情况,经与a局讨论,征收的利息不与个人账户关联, 所有补缴的利息通过账户重新统计进行利息的计算,收取的征收利息和账户产生的利息单算。 2013.9.26 --计算月积数时,最后一年的积数只计算到输入的计息终止年月,而不是计息年度的12月 2013.9.28 --增加字段 AIC042【截止上年末累计缴费月数】、CIC818【本年实缴月数】、CIC819【本年缴费基数和】的记载 */ V_GRJNYE NUMBER(10, 2); V_DWHRYE NUMBER(10, 2); V_GRLJ NUMBER(10, 2); V_ZHLJ NUMBER(10, 2); V_ZHRQ NUMBER(6); V_MINNF NUMBER(4); V_MINNF1 NUMBER(4); --转移年度年份 N_JZQJFLS NUMBER; N_JZQJFJE NUMBER(10, 2); N_JFNF NUMBER; N_GRJFJE NUMBER(10, 2); N_HRZHJE NUMBER(10, 2); N_DQLL NUMBER(7, 6); --NUMBER(4, 4); N_HQLL NUMBER(7, 6); --NUMBER(4, 4); R_ZH_ND SIC86%ROWTYPE; R_ZH_ZR SIC86%ROWTYPE; R_SIC81 SIC81%ROWTYPE; N_SHNF NUMBER(4); V_LJHRLX NUMBER(10, 2); V_LJJNLX NUMBER(10, 2); V_DWJS NUMBER(16, 2); --单位划入部分月积数 V_GRJS NUMBER(16, 2); --个人缴费部分月积数 V_ZR_COUNT NUMBER; V_LS_COUNT NUMBER; V_MSG VARCHAR2(1000); V_COUNT NUMBER; V_RYJBZL PKG_PUB.REC_RYJBZL; --个人基本资料 V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_grndjx_yb‘; V_PROCPARAMS VARCHAR2(3000); V_LXSR_GR NUMBER(12, 2); ---利息收入_个人缴纳 V_LXSR_HR NUMBER(12, 2); ---利息收入_单位划入 V_SIC83 SIC83%ROWTYPE; --账户变更明细表 V_JXKSND NUMBER; --计息开始年度 V_JXZZND NUMBER; --计息终止年度 V_JXYS NUMBER; --计息月数 V_JSZZNY NUMBER(6); --积数终止年月 V_AIC042_SN NUMBER(4); --截止上年末累计缴费月数_上年 V_CIC818_SN NUMBER(4); --本年实缴月数_上年 V_AIC042 NUMBER(4); --截止上年末累计缴费月数 V_CIC819 NUMBER(12, 2); --本年缴费基数和 V_CIC818 NUMBER(4); --本年实缴月数 B_IS_YZDNZFRY BOOLEAN; --是否已征地农转非人员 ---转入的年度账户(可能会存在一年里有多个地方转入的情况) CURSOR C_NDZH(C_ZHND NUMBER) IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE087 = ‘1‘ AND AAE001 = C_ZHND; BEGIN /* --20140828 Added by a: 这个人因为转入的问题,重建账户后,会多出单位划入部分,所以后台处理 if pi_aac001 in (1001399757, 1000990149, 1000915606, 1000731411, 1001236593, 1001320804, 1001253028, 1001405095, 1001380054, 1001096475, 1001308199, 1001308781, 1000183117, 1001075922, 1000191752, 1000110485) then po_fhz := ‘1‘; return; end if; */ --20141013 Modified by a: IF PKG_SXDY_YL.CHECKISHANDWORKPENSIONPSNACCT(PI_AAC001) THEN PO_FHZ := ‘1‘; RETURN; END IF; V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxzzny=‘ || PI_JXZZNY; IF PI_AAE140 NOT IN (‘110‘, ‘120‘) THEN PO_FHZ := ‘1‘; RETURN; END IF; V_JXYS := TO_NUMBER(SUBSTR(PI_JXZZNY, 5, 2)); V_JXZZND := TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)); ---获取计息开始年度(一般情况下,这里计息开始年度与终止年度一致,且为系统当前年度) ---如果系统每年末都已进行计息,那么计息开始年度和终止年度一致 V_JXKSND := V_JXZZND; V_ZR_COUNT := 0; V_MINNF := 0; V_MINNF1 := 0; --查询当前个人基本信息 PKG_BXGX_SHARE.GET_RYJBZL(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --20131206 Added by a: 加入失地农民当年一次性缴费部分的利息计算: B_IS_YZDNZFRY := PKG_SXDY_YL.ISPENSIONPERSON_YZDNZFRY2(PI_AAC001); IF B_IS_YZDNZFRY THEN CALCUSSPECIALACCOUNT_YZDNZFRY(PI_AAC001, ‘110‘, PI_JXZZNY, PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; END IF; --20140723 Added by a: 加入代课教师当年一次性缴费部分的利息计算: IF PKG_SXDY_YL.ISPENSIONPERSON_AGENTTEACHER2(PI_AAC001) THEN CALCUSSPECIALACCOUNT_DKJSRY(PI_AAC001, ‘110‘, PI_JXZZNY, PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; END IF; V_MSG := ‘‘; ---删除计息终止年月所在年度及以后的非转入的年度账户资料 DELETE SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND NVL(AAE087, ‘0‘) = ‘0‘ AND AAE001 >= V_JXZZND; R_ZH_ND.AAC001 := PI_AAC001; R_ZH_ND.AAE140 := PI_AAE140; R_ZH_ND.BAE001 := V_RYJBZL.BAE001; R_ZH_ND.AAB001 := V_RYJBZL.AAB001; R_ZH_ND.AAE087 := ‘0‘; --账户生成类别:0-由系统缴费业务生成 R_ZH_ND.AAE035 := 0; --转入日期 R_ZH_ND.AIC081 := TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmdd‘)); --帐户记息日期 FOR N_JFNF IN V_JXKSND .. V_JXZZND LOOP V_LXSR_GR := 0; V_LXSR_HR := 0; IF N_JFNF < SUBSTR(PI_JXZZNY, 1, 4) THEN V_JSZZNY := TO_NUMBER(N_JFNF || ‘12‘); ELSE V_JSZZNY := PI_JXZZNY; END IF; ---由于这里不是账户重新统计,所以缴费的利息也需要进入计息 + NVL(SUM(AAC124) + NVL(SUM(AAC126) SELECT NVL(SUM(AAC123), 0), --个人缴费金额 NVL(SUM(AAC125), 0), --划入帐户金额 COUNT(DISTINCT CAE121), --费款所属开始年月 NVL(SUM(AAE180), 0) --缴费基数 INTO N_GRJFJE, N_HRZHJE, V_CIC818, V_CIC819 FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND BCE094 = ‘1‘ --缴费标志 AND SUBSTR(CAE121, 1, 4) = N_JFNF ---取审核年月的年度 20130606 从审核年月变为对应年月 a 20130928 AND AAA115 NOT IN (‘90‘, ‘91‘, ‘40‘, ‘41‘); ---不含转入生成的实缴记录 R_ZH_ND.AAE001 := N_JFNF; --账户年度 R_ZH_ND.AIC058 := N_HRZHJE; --划入帐户金额 R_ZH_ND.AIC072 := N_GRJFJE; --个人缴费金额 R_ZH_ND.CIC818 := V_CIC818; --本年实缴月数 R_ZH_ND.CIC819 := V_CIC819; --本年缴费基数和 --取利率 ---企业养老从1996年1月开始计息,本市采用月积数法,所以只获取年记账年利率 ----如果是机关事业养老,则从2003年1月开始计算利息 /* 20131007: Modified by a IF (pi_aae140 = ‘120‘ AND n_jfnf < 2003) or (pi_aae140 = ‘110‘ AND n_jfnf < 1996) THEN n_hqll := 0; n_dqll := 0; Else begin ---获取年记账利率 select aaa031 / 100 into n_dqll from AA03 where AAA030 = ‘91‘ and aae030 = n_jfnf || ‘0101‘ and aae031 = n_jfnf || ‘1231‘; exception WHEN others then po_fhz := ‘-1‘; po_MSG := n_jfnf || ‘年度记帐利率参数缺少,请设置!‘; return; end; END IF; */ PKG_ZHGL_YLLTX.GETACCTYEARLYRATE(N_JFNF, PI_AAE140, N_DQLL, PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; --转换成月利率 N_DQLL := ROUND(N_DQLL / 12, 6); --处理本年度非转入利息 --获取审核年度的利息积数 + nvl(aac124, 0) + nvl(aac126, 0) /* 20131007: Modified by a select nvl(sum((nvl(aac123, 0)) * (v_jszzny - cae121 + 1)), 0), nvl(sum((nvl(aac125, 0)) * (v_jszzny - cae121 + 1)), 0) into v_grjs, v_dwjs from sic84 where aac001 = pi_aac001 and cae121 between to_number(to_char(n_jfnf)||‘01‘) and to_number(to_char(n_jfnf)||‘12‘) and aae140 = pi_aae140 and aaa115 not in (‘90‘, ‘91‘); ---不含转入生成的实缴记录 */ SELECT NVL(SUM((NVL(AAC123, 0)) * (V_JSZZNY - AAE002 + 1)), 0), NVL(SUM((NVL(AAC125, 0)) * (V_JSZZNY - AAE002 + 1)), 0) INTO V_GRJS, V_DWJS FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE002 BETWEEN TO_NUMBER(TO_CHAR(N_JFNF) || ‘01‘) AND V_JSZZNY AND AAE140 = PI_AAE140 AND AAA115 NOT IN (‘90‘, ‘91‘, ‘40‘, ‘41‘); ---不含转入生成的实缴记录 ---记账利率*当年利息积数/12 () R_ZH_ND.AIC075 := V_GRJS * N_DQLL; --本年缴费个人利息 R_ZH_ND.AIC074 := V_DWJS * N_DQLL; --本年缴费划入利息 V_LXSR_GR := V_LXSR_GR + R_ZH_ND.AIC075; V_LXSR_HR := V_LXSR_HR + R_ZH_ND.AIC074; ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) SELECT ROUND(NVL(SUM(AIC079), 0) * N_DQLL * V_JXYS, 2), NVL(SUM(AIC079), 0) INTO R_ZH_ND.AIC076, R_ZH_ND.AIC041 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); V_LXSR_GR := V_LXSR_GR + R_ZH_ND.AIC076; ---获取上年度的累计缴费月数和当年缴费月数,计入本年度的累计缴费月数 (a 2013.09.28) SELECT NVL(SUM(AIC042), 0), NVL(SUM(CIC818), 0) INTO V_AIC042_SN, V_CIC818_SN FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1) AND AAE087 = ‘0‘; ---截止上年末累计缴费月数 R_ZH_ND.AIC042 := V_AIC042_SN + V_CIC818_SN; --个人缴纳累计金额(本金和利息)=历年个人本金+历年个人利息+本年个人本金+本年个人利息 R_ZH_ND.AIC079 := R_ZH_ND.AIC041 + R_ZH_ND.AIC076 + R_ZH_ND.AIC075 + R_ZH_ND.AIC072; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息、历年单位划入 (含历年转入) SELECT ROUND(NVL(SUM(AIC078), 0) * N_DQLL * V_JXYS, 2), NVL(SUM(AIC078), 0) INTO R_ZH_ND.AIC077, R_ZH_ND.AIC040 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); V_LXSR_HR := V_LXSR_HR + R_ZH_ND.AIC077; R_ZH_ND.AIC078 := R_ZH_ND.AIC040 + R_ZH_ND.AIC077 + R_ZH_ND.AIC058 + R_ZH_ND.AIC074; --处理本年度的转入帐户利息 FOR V_NDZH_ZR IN C_NDZH(N_JFNF) LOOP SELECT * INTO R_ZH_ZR FROM SIC86 WHERE AAC001 = V_NDZH_ZR.AAC001 AND AAE140 = V_NDZH_ZR.AAE140 AND AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; R_ZH_ZR.AIC075 := NVL(N_DQLL * (R_ZH_ZR.AIC058 * (N_JFNF || 12 - SUBSTR(R_ZH_ZR.AAE035, 1, 6) + 1)) / 12, 0); --本年缴费个人利息 R_ZH_ZR.AIC074 := NVL(N_DQLL * (R_ZH_ZR.AIC072 * (N_JFNF || 12 - SUBSTR(R_ZH_ZR.AAE035, 1, 6) + 1)) / 12, 0); --本年缴费划入利息 V_LXSR_GR := V_LXSR_GR + R_ZH_ZR.AIC075; V_LXSR_HR := V_LXSR_HR + R_ZH_ZR.AIC074; UPDATE SIC86 SET AIC075 = R_ZH_ZR.AIC075, AIC074 = R_ZH_ZR.AIC074, AIC078 = R_ZH_ZR.AIC074 + R_ZH_ZR.AIC058, AIC079 = R_ZH_ZR.AIC075 + R_ZH_ZR.AIC072 WHERE AAC001 = V_NDZH_ZR.AAC001 AND AAE140 = V_NDZH_ZR.AAE140 AND AAE001 = V_NDZH_ZR.AAE001 AND AAE087 = ‘1‘ AND AAE035 = V_NDZH_ZR.AAE035; --end 处理非本年度的转入(市外转入或者险种转移)帐户利息 END LOOP; INSERT INTO SIC86 VALUES R_ZH_ND; ---记录计息年度的利息收入--这里不能调用下面的利息生成,会对已经产生的利息重算 --直接写入 sic83 IF (V_LXSR_GR + V_LXSR_HR) > 0 THEN SELECT SEQ_BXGX_CAE176.NEXTVAL INTO V_SIC83.CAE176 FROM DUAL; V_SIC83.CAE177 := ‘4‘; V_SIC83.BAE001 := V_RYJBZL.BAE001; V_SIC83.AAB001 := V_RYJBZL.AAB001; V_SIC83.AAC001 := V_RYJBZL.AAC001; V_SIC83.AAE140 := PI_AAE140; V_SIC83.CAE178 := ‘1‘; V_SIC83.CAE230 := ‘23‘; V_SIC83.AAC124 := V_LXSR_GR; V_SIC83.AAC126 := V_LXSR_HR; V_SIC83.CAE233 := PKG_FUN.F_GET_SYSDATE(14); -- 帐户写入时间 V_SIC83.CAE683 := TO_CHAR(SYSDATE, ‘yyyymmdd‘); -- 财务确认时间 V_SIC83.CAE124 := TO_CHAR(SYSDATE, ‘yyyymmdd‘); INSERT INTO SIC83 VALUES V_SIC83; END IF; END LOOP; ---计息完毕后,最后一年的年度账户即为参保人员的当前账户 ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC058), 0) BNBJDW, NVL(SUM(AIC072), 0) BNBJGR, NVL(SUM(AIC074), 0) BNDWLX, NVL(SUM(AIC075), 0) BNGRLX, NVL(SUM(AIC078), 0) DWHRYE, NVL(SUM(AIC079), 0) GRJNYE, NVL(SUM(AIC076), 0) GRLNLX, NVL(SUM(AIC077), 0) DWLNLX INTO R_SIC81.AAE262, R_SIC81.AAE264, R_SIC81.AAE263, R_SIC81.AAE265, R_SIC81.CAC046, R_SIC81.CAC047, R_SIC81.AAE257, R_SIC81.AAE256 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE001 = V_JXKSND AND AAE140 = PI_AAE140; ---历年账户(只取本地业务产生-仅有一条) SELECT NVL(AIC040, 0), NVL(AIC041, 0) INTO R_SIC81.AAE253, R_SIC81.AAE254 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE001 = V_JXKSND AND AAE140 = PI_AAE140 AND AAE087 = ‘0‘; UPDATE SIC81 SET AAE262 = R_SIC81.AAE262, AAE264 = R_SIC81.AAE264, AAE263 = R_SIC81.AAE263, AAE265 = R_SIC81.AAE265, CAC046 = R_SIC81.CAC046, CAC047 = R_SIC81.CAC047, AAE253 = R_SIC81.AAE253, AAE254 = R_SIC81.AAE254, AAE256 = R_SIC81.AAE256, AAE257 = R_SIC81.AAE257 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; IF SQL%NOTFOUND THEN R_SIC81.BAE001 := V_RYJBZL.BAE001; R_SIC81.AAB001 := V_RYJBZL.AAB001; R_SIC81.AAC001 := V_RYJBZL.AAC001; R_SIC81.AAE140 := PI_AAE140; R_SIC81.CAE246 := ‘1‘; INSERT INTO SIC81 VALUES R_SIC81; END IF; PO_FHZ := ‘1‘; PO_MSG := V_MSG; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ylgrzh_grndjx_yb‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END YLGRZH_GRNZJX_YB; --退休人员年中计息 chenqiang 2013-07-09 PROCEDURE LTXRYZH_NZJX_YB(PI_AAC001 AC01.AAC001%TYPE, PI_AAE140 IN VARCHAR2, PI_JXZZNY IN VARCHAR2, ---计息终止年月(离退休死亡人员计息的输入为死亡年月,其他则为系统年月) PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS ----养老账户年中计息(从没有计息的最小年度开始)a 2013.6.20 N_JZLL NUMBER(4, 4); Z_SIC81 SIC81%ROWTYPE; Z_SIC83 SIC83%ROWTYPE; Z_SIC87 SIC87%ROWTYPE; V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ltxryzh_nzjx_yb‘; V_PROCPARAMS VARCHAR2(3000); V_RYJBZL PKG_PUB.REC_RYJBZL; --个人基本资料 V_JXZZND NUMBER; --计息终止年度 V_NCZHDWBFYE NUMBER; --年初账户单位部分余额 V_NCZHGRBFYE NUMBER; --年初账户个人部分余额 V_DNYF NUMBER; --当年月份 V_NY NUMBER; --当年年月 V_ZHGRBFZFJE NUMBER; --账户单位部分支付金额 V_ZHDWBFZFJE NUMBER; --账户个人部分支付金额 V_ZHGRBFZFJEHJ NUMBER; --本年个人部分支付金额合计 V_ZHDWBFZFJEHJ NUMBER; --本年单位部分支付金额合计 V_BNDGRBFZFYJS NUMBER; --本年度支付月积数_个人部分 V_BNDDWBFZFYJS NUMBER; --本年度支付月积数_单位部分 V_BNGRBFLX NUMBER; --本年个人部分利息 V_BNDWBFLX NUMBER; --本年单位部分利息 V_CAC046_BNJXSYE NUMBER; --本年计息时余额 V_CAC047_BNJXSYE NUMBER; --本年计息时余额 BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxzzny=‘ || PI_JXZZNY; IF PI_AAE140 NOT IN (‘110‘, ‘120‘) THEN PO_FHZ := ‘1‘; RETURN; END IF; V_JXZZND := TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)); --计息终止年度 --查询当前个人基本信息 PKG_PUB.RYJBZLCX(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; --取利率 ---企业养老从1996年1月开始计息,本市采用月积数法,所以只获取年记账年利率 ----如果是机关事业养老,则从2003年1月开始计算利息 IF (PI_AAE140 = ‘120‘ AND V_JXZZND < 2003) OR (PI_AAE140 = ‘110‘ AND V_JXZZND < 1996) THEN N_JZLL := 0; ELSE BEGIN ---获取当年度记账利率 SELECT AAA031 / 100 INTO N_JZLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = V_JXZZND || ‘0101‘ AND AAE031 = V_JXZZND || ‘1231‘; IF N_JZLL IS NULL THEN --如果当年度没有公布记账利率,则取上年度的记账利率。 ---获取上年度记账利率 SELECT AAA031 / 100 INTO N_JZLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = V_JXZZND - 1 || ‘0101‘ AND AAE031 = V_JXZZND - 1 || ‘1231‘; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := V_JXZZND - 1 || ‘年度记帐利率参数缺少,请设置!‘; RETURN; END; END IF; V_NCZHDWBFYE := 0; V_NCZHGRBFYE := 0; --取年初账户余额 BEGIN ---获取当年度记账利率 SELECT NVL(CIC809, 0), NVL(CIC810, 0) INTO V_NCZHDWBFYE, V_NCZHGRBFYE FROM SIC87 WHERE AAC001 = PI_AAC001 AND AAE001 = V_JXZZND AND AAE140 = PI_AAE140; EXCEPTION WHEN NO_DATA_FOUND THEN PO_FHZ := ‘-1‘; PO_MSG := ‘该离退休人员在‘ || V_JXZZND || ‘年度的养老离退休人员年度账户没有记录,请核实!‘; RETURN; END; V_DNYF := 1; V_NY := V_JXZZND || ‘01‘; --当年月份 V_ZHGRBFZFJEHJ := 0; --本年个人部分支付金额合计 V_ZHDWBFZFJEHJ := 0; --本年单位部分支付金额合计 V_BNDGRBFZFYJS := 0; --本年度支付月积数_个人部分 V_BNDDWBFZFYJS := 0; --本年度支付月积数_单位部分 WHILE V_NY <= PI_JXZZNY LOOP BEGIN SELECT NVL(AAC123, 0), NVL(AAC125, 0) INTO V_ZHGRBFZFJE, V_ZHDWBFZFJE FROM SIC83 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND CAE178 = ‘2‘ AND AAE003 = V_JXZZND; EXCEPTION WHEN NO_DATA_FOUND THEN V_ZHGRBFZFJE := 0; V_ZHDWBFZFJE := 0; END; V_ZHGRBFZFJEHJ := V_ZHGRBFZFJEHJ + V_ZHGRBFZFJE; V_ZHDWBFZFJEHJ := V_ZHDWBFZFJEHJ + V_ZHDWBFZFJE; V_BNDGRBFZFYJS := V_BNDGRBFZFYJS + V_ZHGRBFZFJE * (12 - V_DNYF + 1); V_BNDDWBFZFYJS := V_BNDDWBFZFYJS + V_ZHDWBFZFJE * (12 - V_DNYF + 1); V_DNYF := V_DNYF + 1; V_NY := TO_CHAR(ADD_MONTHS(TO_DATE(V_NY, ‘yyyyMM‘), 1), ‘yyyyMM‘); END LOOP; --计算本年个部分利息和单位部分利息 V_BNGRBFLX := V_NCZHGRBFYE * N_JZLL - V_BNDGRBFZFYJS * N_JZLL * (1 / 12); V_BNDWBFLX := V_NCZHDWBFYE * N_JZLL - V_BNDDWBFZFYJS * N_JZLL * (1 / 12); Z_SIC87.CIC811 := V_ZHDWBFZFJEHJ; Z_SIC87.CIC812 := V_ZHGRBFZFJEHJ; Z_SIC87.CIC813 := V_NCZHDWBFYE * N_JZLL; Z_SIC87.CIC814 := V_NCZHGRBFYE * N_JZLL; Z_SIC87.CIC815 := V_BNDDWBFZFYJS * N_JZLL * (1 / 12); Z_SIC87.CIC816 := V_BNDGRBFZFYJS * N_JZLL * (1 / 12); Z_SIC87.CIC817 := V_BNDWBFLX + V_BNGRBFLX; Z_SIC87.AIC081 := PKG_FUN.F_GET_SYSDATE(14); Z_SIC87.AAE013 := ‘办理离退休死亡待遇时计息‘; --更新sic87表中的数据 UPDATE SIC87 SET CIC811 = Z_SIC87.CIC811, CIC812 = Z_SIC87.CIC812, CIC813 = Z_SIC87.CIC813, CIC814 = Z_SIC87.CIC814, CIC815 = Z_SIC87.CIC815, CIC816 = Z_SIC87.CIC816, CIC817 = Z_SIC87.CIC817, AIC081 = Z_SIC87.AIC081, AAE013 = Z_SIC87.AAE013 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_JXZZND; SELECT SEQ_BXGX_CAE176.NEXTVAL INTO Z_SIC83.CAE176 FROM DUAL; Z_SIC83.BAE001 := V_RYJBZL.BAE001; Z_SIC83.AAB001 := V_RYJBZL.AAB001; Z_SIC83.AAC001 := PI_AAC001; Z_SIC83.CAE177 := ‘17‘; Z_SIC83.CAE178 := ‘1‘; Z_SIC83.CAE230 := ‘23‘; Z_SIC83.AAE140 := PI_AAE140; Z_SIC83.AAC124 := V_BNGRBFLX; Z_SIC83.AAC126 := V_BNDWBFLX; Z_SIC83.CAE233 := PKG_FUN.F_GET_SYSDATE(14); -- 帐户写入时间 Z_SIC83.CAE683 := TO_CHAR(SYSDATE, ‘yyyymmdd‘); -- 财务确认时间 Z_SIC83.CAE124 := TO_CHAR(SYSDATE, ‘yyyymmdd‘); INSERT INTO SIC83 VALUES Z_SIC83; SELECT CIC809, CIC810 INTO V_CAC046_BNJXSYE, V_CAC047_BNJXSYE FROM SIC87 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_JXZZND; Z_SIC81.CAC046 := V_CAC046_BNJXSYE - V_ZHDWBFZFJEHJ + V_BNDWBFLX; Z_SIC81.CAC047 := V_CAC047_BNJXSYE - V_ZHGRBFZFJEHJ + V_BNGRBFLX; UPDATE SIC81 SET AAE264 = V_BNGRBFLX, AAE263 = V_BNDWBFLX, CAC046 = Z_SIC81.CAC046, CAC047 = Z_SIC81.CAC047 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND CAE246 = ‘1‘; PO_FHZ := ‘1‘; PO_MSG := ‘‘; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ltxryzh_nzjx_yb‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END LTXRYZH_NZJX_YB; --ic35年度结转计息 PROCEDURE IC35_NDJX(PI_AAC001 AC01.AAC001%TYPE, PI_AAE140 IN VARCHAR2, PI_JXKSND IN VARCHAR2, ---计息开始年度 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS N_JFNF NUMBER; N_YLL NUMBER(4, 4); N_NLL NUMBER(4, 4); N_SHNF NUMBER(4); V_MSG VARCHAR2(1000); V_PROCNAME VARCHAR2(100) := ‘ic35_ndjx‘; V_PROCPARAMS VARCHAR2(3000); /*v_aic441 NUMBER(8, 2);*/ N_BNLX NUMBER(6, 2); N_SNLX NUMBER(6, 2); V_COU NUMBER(4); N_SNMBX NUMBER(8, 2); V_SBJG VARCHAR2(14); BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxksnd=‘ || PI_JXKSND; IF PI_AAE140 NOT IN (‘110‘, ‘120‘) THEN PO_FHZ := ‘1‘; RETURN; END IF; V_MSG := ‘‘; SELECT TO_CHAR(SYSDATE, ‘YYYY‘) - 1 INTO N_SHNF FROM DUAL; --获取缴费月数 SELECT COUNT(AAE002) INTO V_COU FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(CAE121, 1, 4) = N_SHNF AND BCE094 = ‘1‘; BEGIN ---获取年记账利率 SELECT AAA031 / 100 INTO N_NLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = PI_JXKSND || ‘0101‘ AND AAE031 = PI_JXKSND || ‘1231‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := N_JFNF || ‘年度记帐利率参数缺少,请设置!‘; RETURN; END; BEGIN ---获取月记账利率 SELECT AAA031 / 100 / 12 INTO N_YLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = PI_JXKSND || ‘0101‘ AND AAE031 = PI_JXKSND || ‘1231‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := N_JFNF || ‘月记帐利率参数缺少,请设置!‘; RETURN; END; SELECT NVL(AIC440, 0) + NVL(AIC441, 0) + NVL(AIC442, 0) + NVL(AIC443, 0) INTO N_SNMBX FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE001 = PI_JXKSND AND AAE140 = PI_AAE140; SELECT NVL(AIC441, 0) * N_YLL * V_COU INTO N_BNLX FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE001 = PI_JXKSND AND AAE140 = PI_AAE140; SELECT NVL(AIC440, 0) * N_NLL INTO N_SNLX FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE001 = PI_JXKSND AND AAE140 = PI_AAE140; UPDATE IC35 --养老保险个人缴统筹 SET AIC442 = N_BNLX, --本年个人缴统筹利息 AIC443 = N_SNLX --截至上年末个人缴统筹本息在本年产生的利息 --aae120 = ‘2‘ --注销标志: 2--已结转 WHERE AAC001 = PI_AAC001 AND AAE001 = PI_JXKSND AND AAE140 = PI_AAE140; SELECT COUNT(*) INTO V_COU FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE001 = PI_JXKSND + 1 AND AAE140 = PI_AAE140; SELECT BAE001 INTO V_SBJG FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE001 = PI_JXKSND AND AAE140 = PI_AAE140; IF V_COU = 0 THEN INSERT INTO IC35 --养老保险个人缴统筹 (BAE001, AAC001, --个人编号 AAE001, --年度 AIC440, --截至上年末个人缴统筹本息 AIC441, --本年个人缴统筹本金 AIC442, --本年个人缴统筹利息 AIC443, --截至上年末个人缴统筹本息在本年产生的利息 --aae120, AAE140) --注销标志 VALUES (V_SBJG, PI_AAC001, --个人编号 PI_JXKSND + 1, --年度 N_SNMBX, --截至上年末个人缴统筹本息 0, --本年个人缴统筹本金 0, --本年个人缴统筹利息 0, --截至上年末个人缴统筹本息在本年产生的利息 --‘0‘, --注销标志 PI_AAE140); END IF; PO_FHZ := ‘1‘; PO_MSG := V_MSG; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ic35_ndjx‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END IC35_NDJX; --ic35历史维护后的计息 PROCEDURE IC35_LSWHJX(PI_AAC001 IN NUMBER, PI_AAE140 IN VARCHAR2, PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS /* 养老保险个人缴统筹--重新计息 a 2013.10.21 计息终止年度应该到当前年度 zhangxuelu 20141212 排除失地农民零星缴费 */ /* Cursor声明 */ CURSOR CUR_IC35 IS SELECT * FROM IC35 --养老保险个人缴统筹 WHERE AAC001 = PI_AAC001 ORDER BY AAE001 ASC; CURSOR C_GRYJ IS SELECT * FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = ‘110‘ AND BCE094 = ‘1‘; N_JFNF NUMBER; N_NLL NUMBER(4, 4); V_MSG VARCHAR2(1000); V_PROCNAME VARCHAR2(100) := ‘ic35_lswhjx‘; V_PROCPARAMS VARCHAR2(3000); N_BNLX NUMBER(6, 2); N_SNLX NUMBER(6, 2); N_SNMBX NUMBER(8, 2); V_COUNT NUMBER; V_MINNF NUMBER; ---最小缴费年份 N_SHNF NUMBER; V_CAE121_MIN NUMBER(6); N_HRTCJE NUMBER(12, 2); ---划入统筹金额 V_RYJBZL PKG_PUB.REC_RYJBZL; --个人基本资料 V_IC35 IC35%ROWTYPE; N_DQLL NUMBER(6, 4); N_HQLL NUMBER(6, 4); V_GRJTCJS NUMBER(16, 2); ---个人缴统筹积数 BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140; IF PI_AAE140 NOT IN (‘110‘, ‘120‘) THEN PO_FHZ := ‘1‘; RETURN; END IF; --查询当前个人基本信息 PKG_BXGX_SHARE.GET_RYJBZL(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_MSG := ‘‘; N_SHNF := TO_CHAR(SYSDATE, ‘yyyy‘); ---删除非转入的年度缴费资料 DELETE IC35 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; ---获取个人身份最小的缴费年月 ---不含转入生成的实缴记录; SELECT NVL(MIN(CAE121), 0) INTO V_CAE121_MIN FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND NVL(CAC089, ‘0‘) IN (‘3‘, ‘5‘) AND AAA115 NOT IN (‘90‘, ‘91‘) AND NOT EXISTS (SELECT 1 FROM IC52 WHERE AAC001 = SIC84.AAC001 AND AAE140 = ‘110‘ AND BCE094 = ‘1‘ AND SIC84.CAE121 BETWEEN CAE121 AND CAE122); --add by zhangxuelu 20141212 排除失地农民零星缴费 IF V_CAE121_MIN = 0 THEN PO_FHZ := ‘1‘; RETURN; END IF; V_MINNF := SUBSTR(V_CAE121_MIN, 1, 4); FOR N_JFNF IN V_MINNF .. N_SHNF LOOP ---由于账户重新统计是逐年计利息,所以若是一次性补缴多年的,其补缴的利息不在这里计入账户 SELECT NVL(SUM(AAC127), 0) INTO N_HRTCJE FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND BCE094 = ‘1‘ AND NVL(CAC089, ‘0‘) IN (‘3‘, ‘5‘) AND SUBSTR(CAE121, 1, 4) = N_JFNF AND AAA115 NOT IN (‘90‘, ‘91‘) ---不含转入生成的实缴记录 AND NOT EXISTS (SELECT 1 FROM IC52 WHERE AAC001 = SIC84.AAC001 AND AAE140 = ‘110‘ AND BCE094 = ‘1‘ AND SIC84.CAE121 BETWEEN CAE121 AND CAE122); --add by zhangxuelu 20141212 排除失地农民零星缴费 V_IC35.AAE001 := N_JFNF; V_IC35.BAE001 := V_RYJBZL.BAE001; V_IC35.AAC001 := PI_AAC001; V_IC35.AAE140 := PI_AAE140; V_IC35.AIC441 := N_HRTCJE; --取利率 ---企业养老从1996年1月开始计息,本市采用月积数法,所以只获取年记账年利率 ----如果是机关事业养老,则从2003年1月开始计算利息 IF (PI_AAE140 = ‘120‘ AND N_JFNF < 2003) OR (PI_AAE140 = ‘110‘ AND N_JFNF < 1996) THEN N_HQLL := 0; N_DQLL := 0; ELSE BEGIN ---获取年记账利率 SELECT AAA031 / 100 INTO N_DQLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = N_JFNF || ‘0101‘ AND AAE031 = N_JFNF || ‘1231‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘-1‘; PO_MSG := N_JFNF || ‘年度记帐利率参数缺少,请设置!‘; RETURN; END; END IF; IF N_SHNF = N_JFNF THEN --当年不计任何利息 V_IC35.AIC442 := 0; V_IC35.AIC443 := 0; ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) SELECT NVL(SUM(AIC440), 0) + NVL(SUM(AIC441), 0) + NVL(SUM(AIC442), 0) + NVL(SUM(AIC443), 0) INTO V_IC35.AIC440 FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); ELSE --获取审核年度的利息积数 SELECT NVL(SUM((NVL(AAC127, 0)) * (N_JFNF || ‘12‘ - CAE121 + 1)), 0) INTO V_GRJTCJS FROM SIC84 WHERE AAC001 = PI_AAC001 AND CAE121 BETWEEN N_JFNF || ‘01‘ AND N_JFNF || ‘12‘ AND AAE140 = PI_AAE140 AND NVL(CAC089, ‘0‘) IN (‘3‘, ‘5‘) AND AAA115 NOT IN (‘90‘, ‘91‘) ---不含转入生成的实缴记录 AND NOT EXISTS (SELECT 1 FROM IC52 WHERE AAC001 = SIC84.AAC001 AND AAE140 = ‘110‘ AND BCE094 = ‘1‘ AND SIC84.CAE121 BETWEEN CAE121 AND CAE122); --add by zhangxuelu 20141212 排除失地农民零星缴费 ---记账利率*当年利息积数/12 () V_IC35.AIC442 := N_DQLL * V_GRJTCJS / 12; --本年个人缴统筹利息 ---截止上年末个人帐户个人缴费部分累计本息在本年产生的利息、历年个人缴纳(含历年转入) SELECT (NVL(SUM(AIC440), 0) + NVL(SUM(AIC441), 0) + NVL(SUM(AIC442), 0) + NVL(SUM(AIC443), 0)) * N_DQLL, NVL(NVL(SUM(AIC440), 0) + SUM(AIC441), 0) + NVL(SUM(AIC442), 0) + NVL(SUM(AIC443), 0) INTO V_IC35.AIC443, V_IC35.AIC440 FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = (N_JFNF - 1); END IF; INSERT INTO IC35 VALUES V_IC35; END LOOP; PO_FHZ := ‘1‘; PO_MSG := V_MSG; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.ic35_lswhjx‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END IC35_LSWHJX; PROCEDURE BCYLGRZH_GRNDJX(PI_AAC001 AC01.AAC001%TYPE, PI_AAE140 IN VARCHAR2, PI_JXKSND IN VARCHAR2, ---计息开始年度 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS /* 2013.8.29 补充养老账户年度计息(从最近一次没有计息的年度开始)a 2 */ V_ZHRQ NUMBER(6); V_MINNF NUMBER(4); N_JFNF NUMBER; N_DQLL NUMBER(4, 4); N_HQLL NUMBER(4, 4); V_NDZH SIC86%ROWTYPE; R_ZH_ZR SIC86%ROWTYPE; R_SIC81 SIC81%ROWTYPE; N_SHNF NUMBER(4); V_LJHRLX NUMBER(10, 2); V_LJJNLX NUMBER(10, 2); V_DWJS NUMBER(16, 2); --单位划入部分月积数 V_GRJS NUMBER(16, 2); --个人缴费部分月积数 V_ZR_COUNT NUMBER; V_LS_COUNT NUMBER; V_MSG VARCHAR2(1000); V_COUNT NUMBER; V_RYJBZL PKG_PUB.REC_RYJBZL; --个人基本资料 V_PROCNAME VARCHAR2(100) := C_PKG_NAME || ‘ylgrzh_grndjx_yb‘; V_PROCPARAMS VARCHAR2(3000); V_LXSR_GR NUMBER(12, 2); ---利息收入_个人缴纳 V_LXSR_HR NUMBER(12, 2); ---利息收入_单位划入 V_SIC83 SIC83%ROWTYPE; --账户变更明细表 V_ND NUMBER; V_AIC079 SIC86.AIC079%TYPE; --个人缴纳累计金额(本金和利息) V_DQLX NUMBER(12, 2); ---定期利息 V_HQLX NUMBER(12, 2); ---活期利息 ---获取补充养老每年的年度账户记录 CURSOR C_NDZH(C_ZHND NUMBER) IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 <= PI_JXKSND ORDER BY AAE001; BEGIN V_PROCPARAMS := ‘,传入参数为:pi_aac001=‘ || PI_AAC001 || ‘,pi_aae140=‘ || PI_AAE140 || ‘,pi_jxksnd=‘ || PI_JXKSND; IF PI_AAE140 <> ‘130‘ THEN PO_FHZ := ‘1‘; RETURN; END IF; --查询当前个人基本信息 PKG_BXGX_SHARE.GET_RYJBZL(PI_AAC001, V_RYJBZL, PO_FHZ, PO_MSG); IF PO_FHZ != ‘1‘ THEN RETURN; END IF; V_MSG := ‘‘; SELECT TO_CHAR(SYSDATE, ‘YYYY‘) INTO N_SHNF FROM DUAL; SELECT NVL(MIN(AAE001), 0) INTO V_MINNF FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; N_JFNF := PI_JXKSND; IF N_JFNF < V_MINNF THEN N_JFNF := V_MINNF; END IF; FOR V_ND IN PI_JXKSND .. N_SHNF LOOP ---获取年记账利率 SELECT AAA031 / 100 INTO N_DQLL FROM AA03 WHERE AAA030 = ‘91‘ AND AAE030 = V_ND || ‘0101‘ AND AAE031 = V_ND || ‘1231‘; N_HQLL := N_DQLL * 1.083 / 2; SELECT COUNT(1) INTO V_LS_COUNT FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_ND; IF V_LS_COUNT = 1 THEN ---存在年度缴费记录,则只需更新年度账户记录中的利息信息和累计信息 SELECT * INTO V_NDZH FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_ND; IF V_ND = V_MINNF THEN ---第一条年度记录,只计当年的活期利息 V_DQLX := 0; ----计算当年的活期利息 V_HQLX := NVL(V_NDZH.AIC072, 0) * N_HQLL; --更新年度账户记录中的利息信息和累计信息 UPDATE SIC86 SET AIC041 = 0, AIC075 = V_HQLX, AIC076 = V_DQLX, AIC079 = NVL(V_NDZH.AIC072, 0) + V_HQLX + V_DQLX WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_ND; ELSE ----获取上年末累计账户金额 SELECT NVL(AIC079, 0) INTO V_AIC079 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_ND - 1; ----计算往年的定期利息 V_DQLX := V_AIC079 * N_DQLL; ----计算当年的活期利息 V_HQLX := NVL(V_NDZH.AIC072, 0) * N_HQLL; --更新年度账户记录中的利息信息和累计信息 UPDATE SIC86 SET AIC041 = V_AIC079, AIC075 = V_HQLX, AIC076 = V_DQLX, AIC079 = V_AIC079 + NVL(V_NDZH.AIC072, 0) + V_HQLX + V_DQLX WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_ND; END IF; ELSE ----获取上年末累计账户金额 SELECT NVL(AIC079, 0) INTO V_AIC079 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = V_ND - 1; ----计算往年的定期利息 V_DQLX := V_AIC079 * N_DQLL; V_HQLX := 0; INSERT INTO SIC86 SELECT V_RYJBZL.BAE001, V_RYJBZL.AAB001, PI_AAC001, V_ND, ‘130‘, NULL, 0, V_AIC079, NULL, 0, 0, 0, 0, V_DQLX, 0, 0, V_AIC079 + V_DQLX, 0, TO_CHAR(SYSDATE, ‘yyyymmdd‘), 0, NULL, NULL FROM DUAL; END IF; END LOOP; ---计息完毕后,最后一年的年度账户即为参保人员的当前账户 ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC058), 0) BNBJDW, NVL(SUM(AIC072), 0) BNBJGR, NVL(SUM(AIC074), 0) BNDWLX, NVL(SUM(AIC075), 0) BNGRLX, NVL(SUM(AIC078), 0) DWHRYE, NVL(SUM(AIC079), 0) GRJNYE, NVL(SUM(AIC076), 0) GRLNLX, NVL(SUM(AIC077), 0) DWLNLX INTO R_SIC81.AAE262, R_SIC81.AAE264, R_SIC81.AAE263, R_SIC81.AAE265, R_SIC81.CAC046, R_SIC81.CAC047, R_SIC81.AAE257, R_SIC81.AAE256 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE001 = N_SHNF AND AAE140 = PI_AAE140; ---历年账户(只去本地业务产生-仅有一条) SELECT NVL(AIC040, 0), NVL(AIC041, 0) INTO R_SIC81.AAE253, R_SIC81.AAE254 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE001 = N_SHNF AND AAE140 = PI_AAE140 AND AAE087 = ‘0‘; R_SIC81.CAE124 := TO_CHAR(SYSDATE, ‘yyyymmddhh24miss‘); UPDATE SIC81 SET AAE262 = R_SIC81.AAE262, AAE264 = R_SIC81.AAE264, AAE263 = R_SIC81.AAE263, AAE265 = R_SIC81.AAE265, CAC046 = R_SIC81.CAC046, CAC047 = R_SIC81.CAC047, AAE253 = R_SIC81.AAE253, AAE254 = R_SIC81.AAE254, AAE257 = R_SIC81.AAE257, AAE256 = R_SIC81.AAE256, CAE124 = R_SIC81.CAE124 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; IF SQL%NOTFOUND THEN R_SIC81.BAE001 := V_RYJBZL.BAE001; R_SIC81.AAB001 := V_RYJBZL.AAB001; R_SIC81.AAC001 := V_RYJBZL.AAC001; R_SIC81.AAE140 := PI_AAE140; R_SIC81.CAE246 := ‘1‘; INSERT INTO SIC81 VALUES R_SIC81; END IF; PO_FHZ := ‘1‘; PO_MSG := V_MSG; RETURN; EXCEPTION WHEN OTHERS THEN PO_FHZ := ‘pkg_zhgl.bcylgrzh_grndjx‘; PO_MSG := PKG_FUN.F_ERRMSG(V_PROCNAME, SQLCODE, SQLERRM, V_PROCPARAMS); RETURN; END BCYLGRZH_GRNDJX; /* 过程名称 :根据a机构、险种类型,获取某年度的年记账利率 功能描述 : 参数描述 : 作 者 :a 完成日期 :2013-09-24 修改记录 : */ PROCEDURE GETACCTYEARINTERESTRATE(PI_BAE001 IN VARCHAR2, --a机构 PI_AAE140 IN VARCHAR2, --险种类型 PI_AAE001 IN INTEGER, --记账年度 PO_YEARRATE OUT NUMBER, --记账利率 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS S_BAE001 VARCHAR2(6); S_AAE140 VARCHAR2(6); FUNCTION CHECK_BAE001 RETURN BOOLEAN IS I_COUNT INTEGER; BEGIN SELECT COUNT(1) INTO I_COUNT FROM AA03 WHERE BAE001 = PI_BAE001 --a机构 AND AAA030 = ‘91‘ --利率滞纳金类型: 记帐年利率 AND AAE030 >= TO_NUMBER(TO_CHAR(PI_AAE001) || ‘0101‘) AND AAE031 <= TO_NUMBER(TO_CHAR(PI_AAE001) || ‘1231‘); RETURN I_COUNT > 0; END CHECK_BAE001; FUNCTION CHECK_AAE140 RETURN BOOLEAN IS I_COUNT INTEGER; BEGIN SELECT COUNT(1) INTO I_COUNT FROM AA03 WHERE AAE140 = PI_AAE140 --险种类型 AND AAA030 = ‘91‘ --利率滞纳金类型: 记帐年利率 AND AAE030 >= TO_NUMBER(TO_CHAR(PI_AAE001) || ‘0101‘) AND AAE031 <= TO_NUMBER(TO_CHAR(PI_AAE001) || ‘1231‘); RETURN I_COUNT > 0; END CHECK_AAE140; BEGIN PO_FHZ := PKG_PUB.DEF_OK; IF CHECK_BAE001() THEN S_BAE001 := PI_BAE001; ELSE S_BAE001 := ‘0‘; END IF; IF CHECK_AAE140() THEN S_AAE140 := PI_AAE140; ELSE S_AAE140 := ‘0‘; END IF; ---获取年记账利率 SELECT AAA031 / 100 INTO PO_YEARRATE FROM AA03 WHERE BAE001 = S_BAE001 --a机构 AND AAE140 = S_AAE140 --险种类型 AND AAA030 = ‘91‘ --利率 AND AAE030 >= TO_NUMBER(TO_CHAR(PI_AAE001) || ‘0101‘) AND AAE031 <= TO_NUMBER(TO_CHAR(PI_AAE001) || ‘1231‘); EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAE001) || ‘, ‘ || PI_AAE140 || ‘获取该年度该险种类型的记账利率系统参数时发生失败:‘ || SQLERRM; END GETACCTYEARINTERESTRATE; /* 过程名称 :根据个人ID和险种类型,获取参保人某年度的缴费月数 功能描述 : 参数描述 : 作 者 :a 完成日期 :2013-09-24 修改记录 : */ PROCEDURE GETPAYMONTHS(PI_AAC001 IN NUMBER, --个人ID PI_AAE140 IN VARCHAR2, --险种类型 PI_AAE001 IN INTEGER, --年度 PO_PAYMONTHS OUT INTEGER, --缴费月数 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS BEGIN PO_FHZ := PKG_PUB.DEF_OK; SELECT NVL(CIC818, 0) --本年实缴月数 INTO PO_PAYMONTHS FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = PI_AAE001; IF PO_PAYMONTHS = 0 THEN SELECT COUNT(AAE002) INTO PO_PAYMONTHS FROM SIC84 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(TO_CHAR(CAE121), 1, 4) = TO_CHAR(PI_AAE001) AND BCE094 = ‘1‘; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAC001) || ‘, ‘ || TO_CHAR(PI_AAE001) || ‘获取该人员该年度养老保险缴费月数时发生失败:‘ || SQLERRM; END GETPAYMONTHS; /* 过程名称 :ic35年中计息 功能描述 :年内计息 参数描述 : 作 者 :a 完成日期 :2013-09-24 修改记录 : */ PROCEDURE IC35_NZJX(PI_AAC001 IN NUMBER, --个人ID PI_AAE140 IN VARCHAR2, --险种类型 PI_JXZZNY IN VARCHAR2, --计息终止年月 PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS N_AIC440 NUMBER(8, 2); --截至上年末个人缴统筹本息 N_AIC441 NUMBER(8, 2); --本年个人缴统筹本金 N_AIC442 NUMBER(8, 2); --本年个人缴统筹利息 N_AIC443 NUMBER(8, 2); --截至上年末个人缴统筹本息在本年产生的利息 S_BAE001 VARCHAR2(6); N_YEARRATE NUMBER(7, 5); N_MONTHLYRATE NUMBER(7, 6); I_PAYMONTHS INTEGER; I_ACCTYEAR INTEGER; FUNCTION DO_NNJX RETURN NUMBER IS I_MONTH INTEGER; N_MONTHLYINCOMEAMT NUMBER(8, 2); N_ACCRUALAMT NUMBER(8, 2); BEGIN N_MONTHLYINCOMEAMT := N_AIC441 / I_PAYMONTHS; N_ACCRUALAMT := 0; FOR I_MONTH IN 1 .. I_PAYMONTHS LOOP --1月份 IF I_MONTH = 1 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --2月份 ELSIF I_MONTH = 2 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --3月份 ELSIF I_MONTH = 3 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --4月份 ELSIF I_MONTH = 4 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --5月份 ELSIF I_MONTH = 5 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --6月份 ELSIF I_MONTH = 6 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --7月份 ELSIF I_MONTH = 7 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --8月份 ELSIF I_MONTH = 8 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --9月份 ELSIF I_MONTH = 9 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --10月份 ELSIF I_MONTH = 10 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --11月份 ELSIF I_MONTH = 11 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); --12月份 ELSIF I_MONTH = 12 THEN N_ACCRUALAMT := N_ACCRUALAMT + N_MONTHLYRATE * N_MONTHLYINCOMEAMT * (I_PAYMONTHS - I_MONTH + 1); END IF; END LOOP; RETURN N_ACCRUALAMT; END DO_NNJX; BEGIN PO_FHZ := PKG_PUB.DEF_OK; I_ACCTYEAR := TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)); SELECT BAE001 INTO S_BAE001 FROM AC01 WHERE AAC001 = PI_AAC001; SELECT NVL(AIC440, 0), NVL(AIC441, 0) INTO N_AIC440, N_AIC441 FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = I_ACCTYEAR; GETACCTYEARINTERESTRATE(S_BAE001, PI_AAE140, I_ACCTYEAR, N_YEARRATE, PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; /* GetPayMonths( pi_aac001, pi_aae140, --险种类型 i_AcctYear, i_PayMonths, --缴费月数 po_fhz, po_msg); if po_fhz <> pkg_pub.def_OK then return; end if; if i_PayMonths = 0 then i_PayMonths := to_number(substr(pi_jxzzny, 5, 2)); end if; */ N_MONTHLYRATE := N_YEARRATE / 12; I_PAYMONTHS := TO_NUMBER(SUBSTR(PI_JXZZNY, 5, 2)); --本年个人缴统筹利息 IF N_AIC441 = 0 THEN N_AIC442 := 0; ELSE N_AIC442 := DO_NNJX(); END IF; --截至上年末个人缴统筹本息在本年产生的利息 N_AIC443 := N_AIC440 * N_MONTHLYRATE * I_PAYMONTHS; UPDATE IC35 SET AIC442 = N_AIC442, --本年个人缴统筹利息 AIC443 = N_AIC443 --截至上年末个人缴统筹本息在本年产生的利息 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = I_ACCTYEAR; EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAC001) || ‘对该人员养老个体缴统筹部分年度账户计息时发生失败:‘ || SQLERRM; END IC35_NZJX; /* 过程名称 :ic35年中计息 功能描述 :年内计息 参数描述 : 作 者 :a 完成日期 :2013-09-24 修改记录 : */ PROCEDURE IC35_ONCERETURN(PI_AAC001 IN NUMBER, --个人ID PI_AAE140 IN VARCHAR2, --险种类型 PI_JXZZNY IN NUMBER, --计息终止年月 PO_RETURNMONEY OUT NUMBER, PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS I_COUNT INTEGER; I_ACCTYEAR INTEGER; D_TEMP DATE; N_CIC135 NUMBER(8, 2); --20141016: PROCEDURE GET_IE01_CIC135 IS BEGIN SELECT NVL(CIC135, 0) --截止本年末个人缴费划拨统筹部分累计储存额(本息) INTO N_CIC135 FROM IE01 WHERE AAC001 = PI_AAC001 AND AAE001 = (SELECT MAX(AAE001) FROM IE01 WHERE AAC001 = PI_AAC001); EXCEPTION WHEN NO_DATA_FOUND THEN N_CIC135 := 0; END GET_IE01_CIC135; --20141126: PROCEDURE GET_IE02_CIC135 IS BEGIN SELECT NVL(CIC135, 0) --截止本年末个人缴费划拨统筹部分累计储存额(本息) INTO N_CIC135 FROM IE02 WHERE AAC001 = PI_AAC001 AND AAE001 = (SELECT MAX(AAE001) FROM IE02 WHERE AAC001 = PI_AAC001); EXCEPTION WHEN NO_DATA_FOUND THEN N_CIC135 := 0; END GET_IE02_CIC135; BEGIN PO_FHZ := PKG_PUB.DEF_OK; PO_RETURNMONEY := 0; IF NOT PI_AAE140 IN (‘110‘, ‘120‘) THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := PI_AAE140 || ‘所传入的养老险种类型不是有效值!‘; RETURN; END IF; BEGIN D_TEMP := TO_DATE(TO_CHAR(PI_JXZZNY), ‘yyyymm‘); EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := PI_JXZZNY || ‘所传入年内计算截止年月不是有效的年月值!请检查。‘; RETURN; END; --20141016 Added by a: GET_IE01_CIC135; PO_RETURNMONEY := PO_RETURNMONEY + NVL(N_CIC135, 0); --20141126 Added by a: GET_IE02_CIC135; PO_RETURNMONEY := PO_RETURNMONEY + NVL(N_CIC135, 0); SELECT COUNT(1) INTO I_COUNT FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140; IF I_COUNT = 0 THEN RETURN; END IF; I_ACCTYEAR := TO_NUMBER(SUBSTR(TO_CHAR(PI_JXZZNY), 1, 4)); SELECT COUNT(1) INTO I_COUNT FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = I_ACCTYEAR; IF I_COUNT = 0 THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAC001) || ‘, ‘ || TO_CHAR(I_ACCTYEAR) || ‘找不到该人该年度的养老个体缴统筹年度账户记录!‘; RETURN; END IF; IC35_NZJX(PI_AAC001, --个人ID PI_AAE140, --险种类型 TO_CHAR(PI_JXZZNY), --计息终止年月 PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; SELECT NVL(AIC440, 0) + NVL(AIC441, 0) + NVL(AIC442, 0) + NVL(AIC443, 0) INTO N_CIC135 FROM IC35 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = I_ACCTYEAR; PO_RETURNMONEY := PO_RETURNMONEY + NVL(N_CIC135, 0); EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAC001) || ‘返还该人员个体缴统筹账户余额时发生失败:‘ || SQLERRM; END IC35_ONCERETURN; /* 过程名称:失地农民当前年度一次性缴费的利息计算 功能描述: 参数描述: 作 者:a 完成日期:2013-12-06 修 改: 完成日期: 修改记录:因业务处理模式变化,本办法已于2013-12-20作废 */ PROCEDURE CALCUSSPECACCT_YZDNZFRY_DISUSE(PI_AAC001 IN NUMBER, PI_AAE140 IN VARCHAR2, PI_JXZZNY IN VARCHAR2, ---计息终止年月(退休计息的输入为退休年月,其他则为系统年月) PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS CURSOR CUR_LIST IS SELECT AAE002, --费款所属期 NVL(AIC453, 0) AIC453, --个人缴纳金额 NVL(AIC021, 0) AIC021, --划入账户金额 AAE015 --复核时间 FROM (SELECT AAE002, --费款所属期 AIC453, --个人缴纳金额 AIC021, --划入账户金额 AAE015 --复核时间 FROM IC51 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(TO_CHAR(AAE015), 1, 4) = SUBSTR(PI_JXZZNY, 1, 4) --复核时间 AND BCE094 = ‘1‘ --缴费标志 UNION ALL SELECT TO_CHAR(AAE002) AAE002, --费款所属期 AIC453, --个人缴纳金额 AIC021, --划入账户金额 AAE015 --复核时间 FROM IC52 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND SUBSTR(TO_CHAR(AAE015), 1, 4) = SUBSTR(PI_JXZZNY, 1, 4) --复核时间 AND BCE094 = ‘1‘ --缴费标志 ); N_DQLL NUMBER(7, 6); --记账利率 ACCOUNTENDMONTH NUMBER(2); PAYMONTH NUMBER(2); N_ACCOUNTAMT_UNIT NUMBER(8, 2); N_ACCOUNTAMT_PSN NUMBER(8, 2); N_CAC046 NUMBER(12, 2); N_CAC047 NUMBER(12, 2); BEGIN PO_FHZ := PKG_PUB.DEF_OK; PKG_ZHGL_YLLTX.GETACCTYEARLYRATE(TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)), PI_AAE140, N_DQLL, PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; --转换成月利率 N_DQLL := ROUND(N_DQLL / 12, 6); ACCOUNTENDMONTH := SUBSTR(PI_JXZZNY, 5, 2); N_ACCOUNTAMT_UNIT := 0; N_ACCOUNTAMT_PSN := 0; FOR REC IN CUR_LIST LOOP PAYMONTH := SUBSTR(TO_CHAR(REC.AAE015), 5, 2); IF PAYMONTH <= ACCOUNTENDMONTH THEN --一次性到账划入的个人账户 X (变动时间 -到账时间)* 月利率 --划入账户金额 N_ACCOUNTAMT_PSN := N_ACCOUNTAMT_PSN + ROUND(REC.AIC021 * (ACCOUNTENDMONTH - PAYMONTH + 1) * N_DQLL, 2); --个人缴纳金额 --n_AccountAmt_Psn := n_AccountAmt_Psn + round(rec.aic453 * (AccountEndMonth - PayMonth + 1) * n_dqll, 2); END IF; END LOOP; IF N_ACCOUNTAMT_UNIT <> 0 OR N_ACCOUNTAMT_PSN <> 0 THEN --20131210 Modified by a /* update sic86 set aic074 = nvl(aic074 , 0) + n_AccountAmt_Unit, --本年缴纳单位缴费划拨部分本年计入利息 aic075 = nvl(aic075 , 0) + n_AccountAmt_Psn, --本年缴纳帐户个人缴费部分本年计入利息 aic078 = nvl(aic078 , 0) + n_AccountAmt_Unit, --单位划入累计金额(本金和利息) aic079 = nvl(aic079 , 0) + n_AccountAmt_Psn, --个人缴纳累计金额(本金和利息 aic081 = to_number(to_char(sysdate, ‘yyyymmdd‘)) --帐户记息日期 where aac001 = pi_aac001 and aae140 = ‘110‘ and aae001 = to_number(substr(pi_jxzzny, 1, 4)) and aae087 = ‘2‘ --账户生成类别:2-失地人员一次性缴费 and rownum = 1; update sic81 set cac046 = nvl(cac046, 0) + n_AccountAmt_Unit, --单位划入余额 cac047 = nvl(cac047, 0) + n_AccountAmt_Psn --个人缴纳余额 where aac001 = pi_aac001 and aae140 = ‘110‘; */ --先清空,再写入 UPDATE SIC86 SET AIC074 = NULL, --本年缴纳单位缴费划拨部分本年计入利息 AIC075 = NULL, --本年缴纳帐户个人缴费部分本年计入利息 AIC078 = NULL, --单位划入累计金额(本金和利息) AIC079 = NULL, --个人缴纳累计金额(本金和利息 AIC081 = NULL --帐户记息日期 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)) AND AAE087 = ‘2‘; --账户生成类别:2-失地人员一次性缴费 UPDATE SIC86 SET AIC074 = N_ACCOUNTAMT_UNIT, --本年缴纳单位缴费划拨部分本年计入利息 AIC075 = N_ACCOUNTAMT_PSN, --本年缴纳帐户个人缴费部分本年计入利息 AIC078 = NVL(AIC040, 0) + NVL(AIC058, 0) + N_ACCOUNTAMT_UNIT + NVL(AIC077, 0), --单位划入累计金额(本金和利息) AIC079 = NVL(AIC041, 0) + NVL(AIC072, 0) + N_ACCOUNTAMT_PSN + NVL(AIC076, 0), --个人缴纳累计金额(本金和利息) AIC081 = TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmdd‘)) --帐户记息日期 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)) AND AAE087 = ‘2‘ --账户生成类别:2-失地人员一次性缴费 AND ROWNUM = 1; ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC078), 0), NVL(SUM(AIC079), 0) INTO N_CAC046, N_CAC047 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)); UPDATE SIC81 SET CAC046 = N_CAC046, --单位划入余额 CAC047 = N_CAC047 --个人缴纳余额 WHERE AAC001 = PI_AAC001 AND AAE140 = ‘110‘; END IF; EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAC001) || ‘计算该失地农民当前年度一次性缴费利息时发生失败:‘ || SQLERRM; END CALCUSSPECACCT_YZDNZFRY_DISUSE; /* 过程名称:失地农民当前年度一次性缴费账户利息计算 功能描述:同一人同一年度可能会有多条一次性缴费账户记录 参数描述: 作 者:a 完成日期:2013-12-20 修 改: 完成日期: 修改记录: */ PROCEDURE CALCUSSPECIALACCOUNT_YZDNZFRY(PI_AAC001 IN NUMBER, PI_AAE140 IN VARCHAR2, PI_JXZZNY IN VARCHAR2, ---计息终止年月(退休计息的输入为退休年月,其他则为系统年月) PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS CURSOR CUR_LIST IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)) AND AAE087 = ‘2‘; --账户生成类别:2-失地人员一次性缴费 N_ACCTRATE NUMBER(8, 6); --记账利率 ACCOUNTENDMONTH NUMBER(2); --计息截止月份 N_ALLOTINMONTH NUMBER(2); --缴费到账划入账户月份 N_AIC074 NUMBER(8, 2); --本年缴纳单位缴费划拨部分本年计入利息 N_AIC075 NUMBER(8, 2); --本年缴纳帐户个人缴费部分本年计入利息 N_AIC076 NUMBER(8, 2); --截止上年末个人帐户个人缴费部分累计本息在本年产生的利息 N_AIC077 NUMBER(8, 2); --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息 N_AIC078 NUMBER(12, 2); --单位划入累计金额(本金和利息) N_AIC079 NUMBER(12, 2); --个人缴纳累计金额(本金和利息 BEGIN PO_FHZ := PKG_PUB.DEF_OK; PKG_ZHGL_YLLTX.GETACCTYEARLYRATE(TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)), PI_AAE140, N_ACCTRATE, PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; --转换成月利率 N_ACCTRATE := ROUND(N_ACCTRATE / 12, 6); ACCOUNTENDMONTH := SUBSTR(PI_JXZZNY, 5, 2); FOR REC IN CUR_LIST LOOP N_AIC074 := 0; --本年缴纳单位缴费划拨部分本年计入利息 N_AIC075 := 0; --本年缴纳帐户个人缴费部分本年计入利息 N_AIC076 := 0; --截止上年末个人帐户个人缴费部分累计本息在本年产生的利息 N_AIC077 := 0; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息 N_ALLOTINMONTH := SUBSTR(TO_CHAR(REC.AAE035), 5, 2); IF NOT N_ALLOTINMONTH IS NULL AND N_ALLOTINMONTH < ACCOUNTENDMONTH THEN --对于当年缴费划入账户金额,从到账的次月起计息 IF NOT REC.AIC058 IS NULL AND REC.AIC058 > 0 THEN N_AIC074 := ROUND(REC.AIC058 * (ACCOUNTENDMONTH - N_ALLOTINMONTH) * N_ACCTRATE, 2); END IF; IF NOT REC.AIC072 IS NULL AND REC.AIC072 > 0 THEN N_AIC075 := ROUND(REC.AIC072 * (ACCOUNTENDMONTH - N_ALLOTINMONTH) * N_ACCTRATE, 2); END IF; END IF; IF NOT REC.AIC040 IS NULL AND REC.AIC040 > 0 THEN N_AIC077 := ROUND(REC.AIC040 * (ACCOUNTENDMONTH - N_ALLOTINMONTH + 1) * N_ACCTRATE, 2); END IF; IF NOT REC.AIC041 IS NULL AND REC.AIC041 > 0 THEN N_AIC076 := ROUND(REC.AIC041 * (ACCOUNTENDMONTH - N_ALLOTINMONTH + 1) * N_ACCTRATE, 2); END IF; --单位划入累计金额(本金和利息) N_AIC078 := NVL(REC.AIC040, 0) + NVL(REC.AIC058, 0) + NVL(N_AIC074, 0) + NVL(N_AIC077, 0); --个人缴纳累计金额(本金和利息 N_AIC079 := NVL(REC.AIC041, 0) + NVL(REC.AIC072, 0) + NVL(N_AIC075, 0) + NVL(N_AIC076, 0); UPDATE SIC86 SET AIC074 = N_AIC074, AIC075 = N_AIC075, AIC076 = N_AIC076, AIC077 = N_AIC077, AIC078 = N_AIC078, AIC079 = N_AIC079, AIC081 = TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmdd‘)) --帐户记息日期 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)) AND AAE087 = ‘2‘ --账户生成类别:2-失地人员一次性缴费 AND AAE035 = REC.AAE035; --转入日期 END LOOP; ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC078), 0), NVL(SUM(AIC079), 0) INTO N_AIC078, N_AIC079 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)); UPDATE SIC81 SET CAC046 = N_AIC078, --单位划入余额 CAC047 = N_AIC079 --个人缴纳余额 WHERE AAC001 = PI_AAC001 AND AAE140 = ‘110‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAC001) || ‘计算该失地农民当前年度一次性缴费利息时发生失败:‘ || SQLERRM; END CALCUSSPECIALACCOUNT_YZDNZFRY; /* 过程名称:代课教师当前年度一次性缴费账户利息计算 功能描述:同一人同一年度可能会有多条一次性缴费账户记录 参数描述: 作 者:a 完成日期:2014-07-23 修 改: 完成日期: 修改记录: */ PROCEDURE CALCUSSPECIALACCOUNT_DKJSRY(PI_AAC001 IN NUMBER, PI_AAE140 IN VARCHAR2, PI_JXZZNY IN VARCHAR2, ---计息终止年月(退休计息的输入为退休年月,其他则为系统年月) PO_FHZ OUT VARCHAR2, PO_MSG OUT VARCHAR2) IS CURSOR CUR_LIST IS SELECT * FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)) AND AAE087 = ‘4‘; --账户生成类别:4-代课教师一次性缴费 N_ACCTRATE NUMBER(8, 6); --记账利率 ACCOUNTENDMONTH NUMBER(2); --计息截止月份 N_ALLOTINMONTH NUMBER(2); --缴费到账划入账户月份 N_AIC074 NUMBER(8, 2); --本年缴纳单位缴费划拨部分本年计入利息 N_AIC075 NUMBER(8, 2); --本年缴纳帐户个人缴费部分本年计入利息 N_AIC076 NUMBER(8, 2); --截止上年末个人帐户个人缴费部分累计本息在本年产生的利息 N_AIC077 NUMBER(8, 2); --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息 N_AIC078 NUMBER(12, 2); --单位划入累计金额(本金和利息) N_AIC079 NUMBER(12, 2); --个人缴纳累计金额(本金和利息 BEGIN PO_FHZ := PKG_PUB.DEF_OK; PKG_ZHGL_YLLTX.GETACCTYEARLYRATE(TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)), PI_AAE140, N_ACCTRATE, PO_FHZ, PO_MSG); IF PO_FHZ <> PKG_PUB.DEF_OK THEN RETURN; END IF; --转换成月利率 N_ACCTRATE := ROUND(N_ACCTRATE / 12, 6); ACCOUNTENDMONTH := SUBSTR(PI_JXZZNY, 5, 2); FOR REC IN CUR_LIST LOOP N_AIC074 := 0; --本年缴纳单位缴费划拨部分本年计入利息 N_AIC075 := 0; --本年缴纳帐户个人缴费部分本年计入利息 N_AIC076 := 0; --截止上年末个人帐户个人缴费部分累计本息在本年产生的利息 N_AIC077 := 0; --截止上年末个人帐户单位划拨部分累计本息在本年产生的利息 N_ALLOTINMONTH := SUBSTR(TO_CHAR(REC.AAE035), 5, 2); IF NOT N_ALLOTINMONTH IS NULL AND N_ALLOTINMONTH < ACCOUNTENDMONTH THEN --对于当年缴费划入账户金额,从到账的次月起计息 IF NOT REC.AIC058 IS NULL AND REC.AIC058 > 0 THEN N_AIC074 := ROUND(REC.AIC058 * (ACCOUNTENDMONTH - N_ALLOTINMONTH) * N_ACCTRATE, 2); END IF; IF NOT REC.AIC072 IS NULL AND REC.AIC072 > 0 THEN N_AIC075 := ROUND(REC.AIC072 * (ACCOUNTENDMONTH - N_ALLOTINMONTH) * N_ACCTRATE, 2); END IF; END IF; IF NOT REC.AIC040 IS NULL AND REC.AIC040 > 0 THEN N_AIC077 := ROUND(REC.AIC040 * (ACCOUNTENDMONTH - N_ALLOTINMONTH + 1) * N_ACCTRATE, 2); END IF; IF NOT REC.AIC041 IS NULL AND REC.AIC041 > 0 THEN N_AIC076 := ROUND(REC.AIC041 * (ACCOUNTENDMONTH - N_ALLOTINMONTH + 1) * N_ACCTRATE, 2); END IF; --单位划入累计金额(本金和利息) N_AIC078 := NVL(REC.AIC040, 0) + NVL(REC.AIC058, 0) + NVL(N_AIC074, 0) + NVL(N_AIC077, 0); --个人缴纳累计金额(本金和利息 N_AIC079 := NVL(REC.AIC041, 0) + NVL(REC.AIC072, 0) + NVL(N_AIC075, 0) + NVL(N_AIC076, 0); UPDATE SIC86 SET AIC074 = N_AIC074, AIC075 = N_AIC075, AIC076 = N_AIC076, AIC077 = N_AIC077, AIC078 = N_AIC078, AIC079 = N_AIC079, AIC081 = TO_NUMBER(TO_CHAR(SYSDATE, ‘yyyymmdd‘)) --帐户记息日期 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)) AND AAE087 = ‘4‘ --账户生成类别:4-代课教师一次性缴费 AND AAE035 = REC.AAE035; --转入日期 END LOOP; ---当年账户及累计账户(含本地和转入) SELECT NVL(SUM(AIC078), 0), NVL(SUM(AIC079), 0) INTO N_AIC078, N_AIC079 FROM SIC86 WHERE AAC001 = PI_AAC001 AND AAE140 = PI_AAE140 AND AAE001 = TO_NUMBER(SUBSTR(PI_JXZZNY, 1, 4)); UPDATE SIC81 SET CAC046 = N_AIC078, --单位划入余额 CAC047 = N_AIC079 --个人缴纳余额 WHERE AAC001 = PI_AAC001 AND AAE140 = ‘110‘; EXCEPTION WHEN OTHERS THEN PO_FHZ := PKG_PUB.DEF_ERR; PO_MSG := TO_CHAR(PI_AAC001) || ‘计算该代课教师当前年度一次性缴费利息时发生失败:‘ || SQLERRM; END CALCUSSPECIALACCOUNT_DKJSRY; END PKG_ZHGL;
标签:
原文地址:http://www.cnblogs.com/Sunnor/p/4692635.html