|
@@ -59,10 +59,13 @@ class PaymentOperationView(View):
|
|
|
MF_LZ1_NO = cursor.execute("""SELECT COUNT(*) FROM MF_ARP WHERE ARP_NO=%s""", ['AP' + MF_LZ1[2::]]).fetchall()[0][0]
|
|
|
if MF_LZ1_NO<=0:
|
|
|
return http.HttpResponseForbidden('开票单号不存在')
|
|
|
+
|
|
|
+ # 获取银行账号的会计科目
|
|
|
+ Acc_No_km = cursor.execute("""SELECT Acc_No FROM BACC WHERE BACC_NO=%s""", [CACC_NO]).fetchall()[0][0]
|
|
|
+ if Acc_No_km == '':
|
|
|
+ return http.HttpResponseForbidden('银行会计科目不存在')
|
|
|
sid = transaction.savepoint() #开启事物
|
|
|
try:
|
|
|
- # 获取银行账号的会计科目
|
|
|
- Acc_No_km = cursor.execute("""SELECT Acc_No FROM BACC WHERE BACC_NO=%s""",[CACC_NO]).fetchall()[0][0]
|
|
|
|
|
|
# cursor.execute("""UPDATE TF_PSS SET AMT_FP=%s,AMTN_NET_FP=%s WHERE PS_NO=%s""",[AMT, AMT, 'PC' + ZL_NO[2::]])
|
|
|
#插入付款单表头
|
|
@@ -185,6 +188,8 @@ class PaymentOperationView(View):
|
|
|
return http.HttpResponseForbidden('开票单号不存在')
|
|
|
# 获取银行账号的会计科目
|
|
|
Acc_No_km = cursor.execute("""SELECT Acc_No FROM BACC WHERE BACC_NO=%s""", [CACC_NO]).fetchall()[0][0]
|
|
|
+ if Acc_No_km == '':
|
|
|
+ return http.HttpResponseForbidden('银行会计科目不存在')
|
|
|
|
|
|
# 缓存之前冲款的金额用于回写立账冲款数据
|
|
|
row_AMTN = cursor.execute("""SELECT AMTN_BC FROM TF_MON WHERE RP_NO=%s AND RP_ID='2'""", [RP_NO]).fetchall()[0][0]
|
|
@@ -333,6 +338,7 @@ class ExpectedOperationView(View):
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
|
|
|
+ @transaction.atomic
|
|
|
def post(self, request):
|
|
|
# 获取参数
|
|
|
RP_NO = request.POST.get("RP_NO") # 预付款单号 字符类型 ----------------1
|
|
@@ -346,7 +352,7 @@ class ExpectedOperationView(View):
|
|
|
# 判断单号是否存在
|
|
|
row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO,'RP_ID','2')
|
|
|
if row_ZL_NO > 0:
|
|
|
- return http.HttpResponseForbidden('单号重复')
|
|
|
+ return http.HttpResponseForbidden('预付款单号已存在')
|
|
|
|
|
|
# 判断用户是否存在,不存在则创建
|
|
|
row_usr = usr_data(USR, USR_NAME, datetime.datetime.strptime(RP_DD, '%Y-%m-%d'))
|
|
@@ -355,56 +361,69 @@ class ExpectedOperationView(View):
|
|
|
row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2', datetime.datetime.strptime(RP_DD, '%Y-%m-%d'))
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
- cursor.execute("""INSERT INTO TF_MON(IRP_ID,RP_NO,ITM,RP_ID,CLS_ID,RP_DD,CUS_NO,INCLUDESON,AMTN_BC,AMTN_CLS,BC_NO,CACC_NO,EXC_RTO,DEP,USR,CHK_MAN,CLS_DATE,SYS_DATE,IEA_ID,IOR_ID,SK_TYPE)VALUES
|
|
|
- ('T',%s,1,2,'F',%s,%s,'F',%s,0,%s,%s,1,'0000',%s,%s,%s,%s,'F','F',1)""",
|
|
|
- [RP_NO, datetime.datetime.strptime(RP_DD, '%Y-%m-%d'), CUS_NO,AMTN_BC,'BT'+RP_NO[2::],CACC_NO,USR,USR,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),datetime.datetime.strptime(RP_DD, '%Y-%m-%d')])
|
|
|
- # RP_NO 预付款单号 RP_NO
|
|
|
- # RP_DD 预付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- #CUS_NO 客户编码 CUS_NO
|
|
|
- #AMTN_BC 预付款金额 AMTN_BC
|
|
|
- #BC_NO 账户收支单号 'BT'+RP_NO[2::]
|
|
|
- # CACC_NO 付款银行编码 CACC_NO
|
|
|
- #USR 制单人 USR
|
|
|
- #CHK_MAN 审核人 USR
|
|
|
- # CLS_DATE 审核时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # SYS_DATE 制单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
-
|
|
|
- # 插入立账金额
|
|
|
- # cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s", [MF_LZ1])
|
|
|
- cursor.execute("""INSERT INTO MF_MON(RP_ID,RP_NO,RP_DD,DEP,AMTN,AMTN_ARP,AMTN_REST,FJ_NUM)VALUES
|
|
|
- (2,%s,%s,'0000',%s,0,0,0)""" ,[RP_NO,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC])
|
|
|
- # RP_NO 单号 RP_NO
|
|
|
- # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # AMTN 金额 AMTN_BC
|
|
|
-
|
|
|
- # 插入账户收支单表头
|
|
|
- cursor.execute("""INSERT INTO MF_BAC(BB_ID,BB_NO,BB_DD,BACC_NO,ACC_NO,DEP,BIL_NO,EXC_RTO,AMTN,USR,CHK_MAN,OPN_ID,CLS_DATE,SYS_DATE,BIL_ID_N,BIL_NO_N)VALUES
|
|
|
- ('BT',%s,%s,%s,100903,'0000',%s,1,%s,%s,%s,'F',%s,%s,'PT',%s)""",
|
|
|
- ['BT'+RP_NO[2::],datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CACC_NO,'BT'+RP_NO,-float(AMTN_BC),USR,USR,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),
|
|
|
- RP_NO])
|
|
|
- #BB_NO 收支单号 'BT'+RP_NO[2::]
|
|
|
- #BB_DD 账户收支单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- #BACC_NO 银行账号编码 CACC_NO
|
|
|
- #ACC_NO 会计科目先固定 100903
|
|
|
- #BIL_NO 来源单号 'BT'+RP_NO
|
|
|
- #AMTN 收支单金额 -float(AMTN_BC)
|
|
|
- #USR 制单人 USR
|
|
|
- #审核人 CHK_MAN
|
|
|
- #CLS_DATE 审核人
|
|
|
- #SYS_DATE 制单人
|
|
|
-
|
|
|
- #插入收支单表身
|
|
|
- cursor.execute("""INSERT INTO TF_BAC(BB_ID,BB_NO,ITM,BB_DD,EXC_RTO,AMTN,DEP,CUS_NO,ADD_ID,PRE_ITM)values
|
|
|
- ('BT',%s,1,%s,1,%s,%s,'51','-',1)""", ['BT'+RP_NO[2::],datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC,CUS_NO])
|
|
|
- # BB_NO 单号 'BT'+RP_NO[2::]
|
|
|
- #BB_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- #AMTN 金额 AMTN_BC
|
|
|
- #CUS_NO 客户编码 CUS_NO
|
|
|
+ # 获取银行账号的会计科目
|
|
|
+ Acc_No_km = cursor.execute("""SELECT ISNULL(Acc_No,'') FROM BACC WHERE BACC_NO=%s""", [CACC_NO]).fetchall()[0][0]
|
|
|
+ print(Acc_No_km)
|
|
|
+ if Acc_No_km=='':
|
|
|
+ return http.HttpResponseForbidden('银行会计科目不存在')
|
|
|
+
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
+ try:
|
|
|
+ cursor.execute("""INSERT INTO TF_MON(IRP_ID,RP_NO,ITM,RP_ID,CLS_ID,RP_DD,CUS_NO,INCLUDESON,AMTN_BC,AMTN_CLS,BC_NO,CACC_NO,EXC_RTO,DEP,USR,CHK_MAN,CLS_DATE,SYS_DATE,IEA_ID,IOR_ID,SK_TYPE)VALUES
|
|
|
+ ('T',%s,1,2,'F',%s,%s,'F',%s,0,%s,%s,1,'0000',%s,%s,%s,%s,'F','F',1)""",
|
|
|
+ [RP_NO, datetime.datetime.strptime(RP_DD, '%Y-%m-%d'), CUS_NO,AMTN_BC,'BT'+RP_NO[2::],CACC_NO,USR,USR,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),datetime.datetime.strptime(RP_DD, '%Y-%m-%d')])
|
|
|
+ # RP_NO 预付款单号 RP_NO
|
|
|
+ # RP_DD 预付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ #CUS_NO 客户编码 CUS_NO
|
|
|
+ #AMTN_BC 预付款金额 AMTN_BC
|
|
|
+ #BC_NO 账户收支单号 'BT'+RP_NO[2::]
|
|
|
+ # CACC_NO 付款银行编码 CACC_NO
|
|
|
+ #USR 制单人 USR
|
|
|
+ #CHK_MAN 审核人 USR
|
|
|
+ # CLS_DATE 审核时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # SYS_DATE 制单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+
|
|
|
+ # 插入立账金额
|
|
|
+ # cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s", [MF_LZ1])
|
|
|
+ cursor.execute("""INSERT INTO MF_MON(RP_ID,RP_NO,RP_DD,DEP,AMTN,AMTN_ARP,AMTN_REST,FJ_NUM)VALUES
|
|
|
+ (2,%s,%s,'0000',%s,0,0,0)""" ,[RP_NO,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC])
|
|
|
+ # RP_NO 单号 RP_NO
|
|
|
+ # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # AMTN 金额 AMTN_BC
|
|
|
+
|
|
|
+ # 插入账户收支单表头
|
|
|
+ cursor.execute("""INSERT INTO MF_BAC(BB_ID,BB_NO,BB_DD,BACC_NO,ACC_NO,DEP,BIL_NO,EXC_RTO,AMTN,USR,CHK_MAN,OPN_ID,CLS_DATE,SYS_DATE,BIL_ID_N,BIL_NO_N)VALUES
|
|
|
+ ('BT',%s,%s,%s,%s,'0000',%s,1,%s,%s,%s,'F',%s,%s,'PT',%s)""",
|
|
|
+ ['BT'+RP_NO[2::],datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CACC_NO,'BT'+RP_NO,-float(AMTN_BC),Acc_No_km,USR,USR,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),
|
|
|
+ RP_NO])
|
|
|
+ #BB_NO 收支单号 'BT'+RP_NO[2::]
|
|
|
+ #BB_DD 账户收支单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ #BACC_NO 银行账号编码 CACC_NO
|
|
|
+ #ACC_NO 会计科目先固定 100903
|
|
|
+ #BIL_NO 来源单号 'BT'+RP_NO
|
|
|
+ #AMTN 收支单金额 -float(AMTN_BC)
|
|
|
+ #USR 制单人 USR
|
|
|
+ #审核人 CHK_MAN
|
|
|
+ #CLS_DATE 审核人
|
|
|
+ #SYS_DATE 制单人
|
|
|
+
|
|
|
+ #插入收支单表身
|
|
|
+ cursor.execute("""INSERT INTO TF_BAC(BB_ID,BB_NO,ITM,BB_DD,EXC_RTO,AMTN,DEP,CUS_NO,ADD_ID,PRE_ITM)values
|
|
|
+ ('BT',%s,1,%s,1,%s,%s,'51','-',1)""", ['BT'+RP_NO[2::],datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC,CUS_NO])
|
|
|
+ # BB_NO 单号 'BT'+RP_NO[2::]
|
|
|
+ #BB_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ #AMTN 金额 AMTN_BC
|
|
|
+ #CUS_NO 客户编码 CUS_NO
|
|
|
+ except Exception:
|
|
|
+ transaction.savepoint_rollback(sid)
|
|
|
+ return http.HttpResponseForbidden("预计付款单新增sql语句执行异常")
|
|
|
+ transaction.savepoint_commit(sid)
|
|
|
context = {
|
|
|
'a': 'post预付款作业'
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
|
|
|
+ @transaction.atomic
|
|
|
def put(self, request):
|
|
|
# 获取参数
|
|
|
req_data = json.loads(request.body.decode())
|
|
@@ -427,53 +446,70 @@ class ExpectedOperationView(View):
|
|
|
# 判断单号是否存在
|
|
|
row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO,'RP_ID','2')
|
|
|
if row_ZL_NO == 0:
|
|
|
- return http.HttpResponseForbidden('单号不存在')
|
|
|
+ return http.HttpResponseForbidden('预付款单号不存在')
|
|
|
+
|
|
|
+ # 判断单号是不是已经产生付款单
|
|
|
+ row_ZL_NO = examine_ood('TF_MON1', 'IRP_NO', RP_NO, 'RP_ID', '2')
|
|
|
+ if row_ZL_NO > 0:
|
|
|
+ return http.HttpResponseForbidden('预付款单已经产生付款单')
|
|
|
|
|
|
# 判断客户资料是否存在,不存在则创建
|
|
|
row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2', datetime.datetime.strptime(RP_DD, '%Y-%m-%d'))
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
- # 修改预付款单
|
|
|
- # cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s", [MF_LZ1])
|
|
|
- cursor.execute("""UPDATE TF_MON SET RP_DD=%s,CUS_NO=%s,AMTN_BC=%s,BC_NO=%s,CACC_NO=%s,MODIFY_DD=%s,MODIFY_MAN=USR WHERE RP_NO=%s""",
|
|
|
- [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CUS_NO,AMTN_BC,'BT'+RP_NO[2::],CACC_NO,UP_DD,RP_NO])
|
|
|
-
|
|
|
- # RP_NO 预付款单号 RP_NO
|
|
|
- # RP_DD 预付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # CUS_NO 客户编码 CUS_NO
|
|
|
- # AMTN_BC 预付款金额 AMTN_BC
|
|
|
- # BC_NO 账户收支单号 'BT'+RP_NO[2::]
|
|
|
- # CACC_NO 付款银行编码 CACC_NO
|
|
|
- #修改立账单金额
|
|
|
-
|
|
|
- cursor.execute("""UPDATE MF_MON SET RP_DD=%s,AMTN=%s WHERE RP_NO=%s""", [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC,RP_NO])
|
|
|
- # RP_NO 单号 RP_NO
|
|
|
- # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # AMTN 金额 AMTN_BC
|
|
|
-
|
|
|
- #修改账户收支单表头
|
|
|
- cursor.execute("""UPDATE MF_BAC SET BB_DD=%s,BACC_NO=%s,ACC_NO=%s,BIL_NO=%s,AMTN=%s WHERE BB_NO=%s""",
|
|
|
- [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CACC_NO,100903,'BT'+RP_NO,-float(AMTN_BC),'BT'+RP_NO[2::]])
|
|
|
- # BB_NO 收支单号 'BT'+MF_LZ1[2::]
|
|
|
- # BB_DD 账户收支单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # BACC_NO 银行账号编码 CACC_NO
|
|
|
- # ACC_NO 会计科目先固定 100903
|
|
|
- # BIL_NO 来源单号 'BT'+RP_NO
|
|
|
- # AMTN 收支单金额 -float(AMTN_BC)
|
|
|
-
|
|
|
- # 修改立账单表身
|
|
|
-
|
|
|
- cursor.execute("""UPDATE TF_BAC SET BB_DD=%s,AMTN=%s,CUS_NO=%s WHERE BB_NO=%s""", [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC,CUS_NO,'BT'+RP_NO[2::]])
|
|
|
- # BB_NO 单号 'BT'+RP_NO[2::]
|
|
|
- # BB_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # AMTN 金额 AMTN_BC
|
|
|
- # CUS_NO 客户编码 CUS_NO
|
|
|
+ # 获取银行账号的会计科目
|
|
|
+ Acc_No_km = cursor.execute("""SELECT Acc_No FROM BACC WHERE BACC_NO=%s""", [CACC_NO]).fetchall()[0][0]
|
|
|
+
|
|
|
+ if Acc_No_km=='':
|
|
|
+ return http.HttpResponseForbidden('银行会计科目不存在')
|
|
|
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
+ try:
|
|
|
+ # 修改预付款单
|
|
|
+ # cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s", [MF_LZ1])
|
|
|
+ cursor.execute("""UPDATE TF_MON SET RP_DD=%s,CUS_NO=%s,AMTN_BC=%s,BC_NO=%s,CACC_NO=%s,MODIFY_DD=%s,MODIFY_MAN=USR WHERE RP_NO=%s""",
|
|
|
+ [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CUS_NO,AMTN_BC,'BT'+RP_NO[2::],CACC_NO,UP_DD,RP_NO])
|
|
|
+
|
|
|
+ # RP_NO 预付款单号 RP_NO
|
|
|
+ # RP_DD 预付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # CUS_NO 客户编码 CUS_NO
|
|
|
+ # AMTN_BC 预付款金额 AMTN_BC
|
|
|
+ # BC_NO 账户收支单号 'BT'+RP_NO[2::]
|
|
|
+ # CACC_NO 付款银行编码 CACC_NO
|
|
|
+ #修改立账单金额
|
|
|
+
|
|
|
+ cursor.execute("""UPDATE MF_MON SET RP_DD=%s,AMTN=%s WHERE RP_NO=%s""", [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC,RP_NO])
|
|
|
+ # RP_NO 单号 RP_NO
|
|
|
+ # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # AMTN 金额 AMTN_BC
|
|
|
+
|
|
|
+ #修改账户收支单表头
|
|
|
+ cursor.execute("""UPDATE MF_BAC SET BB_DD=%s,BACC_NO=%s,ACC_NO=%s,BIL_NO=%s,AMTN=%s WHERE BB_NO=%s""",
|
|
|
+ [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CACC_NO,Acc_No_km,'BT'+RP_NO,-float(AMTN_BC),'BT'+RP_NO[2::]])
|
|
|
+ # BB_NO 收支单号 'BT'+MF_LZ1[2::]
|
|
|
+ # BB_DD 账户收支单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # BACC_NO 银行账号编码 CACC_NO
|
|
|
+ # ACC_NO 会计科目先固定 100903
|
|
|
+ # BIL_NO 来源单号 'BT'+RP_NO
|
|
|
+ # AMTN 收支单金额 -float(AMTN_BC)
|
|
|
+
|
|
|
+ # 修改立账单表身
|
|
|
+
|
|
|
+ cursor.execute("""UPDATE TF_BAC SET BB_DD=%s,AMTN=%s,CUS_NO=%s WHERE BB_NO=%s""", [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),AMTN_BC,CUS_NO,'BT'+RP_NO[2::]])
|
|
|
+ # BB_NO 单号 'BT'+RP_NO[2::]
|
|
|
+ # BB_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # AMTN 金额 AMTN_BC
|
|
|
+ # CUS_NO 客户编码 CUS_NO
|
|
|
+ except Exception:
|
|
|
+ transaction.savepoint_rollback(sid)
|
|
|
+ return http.HttpResponseForbidden("预计付款单修改sql语句执行异常")
|
|
|
+ transaction.savepoint_commit(sid)
|
|
|
context = {
|
|
|
'a': 'put预付款作业'
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
|
|
|
+ @transaction.atomic
|
|
|
def delete(self, request):
|
|
|
#获取参数
|
|
|
req_data = json.loads(request.body.decode())
|
|
@@ -488,31 +524,38 @@ class ExpectedOperationView(View):
|
|
|
# "CACC_NO":"01"
|
|
|
# }
|
|
|
# 判断单号是不是已经产生付款单
|
|
|
- row_ZL_NO = examine_ood('TF_MON', 'IRP_NO', RP_NO,'RP_NO','2')
|
|
|
+ row_ZL_NO = examine_ood('TF_MON1', 'IRP_NO', RP_NO,'RP_ID','2')
|
|
|
if row_ZL_NO > 0:
|
|
|
- return http.HttpResponseForbidden('预付款单已经产生付款单')
|
|
|
+ return http.HttpResponseForbidden ('预付款单已经产生付款单')
|
|
|
|
|
|
# 判断单号是否存在
|
|
|
- row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO,'RP_NO','2')
|
|
|
+ row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO,'RP_ID','2')
|
|
|
if row_ZL_NO == 0:
|
|
|
- return http.HttpResponseForbidden('单号不存在')
|
|
|
+ return http.HttpResponseForbidden('预付款单号不存在')
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
- # 修改预付款单
|
|
|
- # cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s", [MF_LZ1])
|
|
|
- #删除付款单
|
|
|
- cursor.execute("""DELETE FROM TF_MON WHERE RP_NO=%s""", [RP_NO])
|
|
|
- # 删除金额立账单
|
|
|
- cursor.execute("""DELETE FROM MF_MON WHERE RP_NO=%s""", [RP_NO])
|
|
|
- #删除账户收支单表头
|
|
|
- cursor.execute("""DELETE FROM MF_BAC WHERE BB_NO=%s""", ['BT'+RP_NO[2::]])
|
|
|
- #删除账户收支单表身
|
|
|
- cursor.execute("""DELETE FROM TF_BAC WHERE BB_NO=%s""", ['BT'+RP_NO[2::]])
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
+ try:
|
|
|
+ # 修改预付款单
|
|
|
+ # cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s", [MF_LZ1])
|
|
|
+ #删除付款单
|
|
|
+ cursor.execute("""DELETE FROM TF_MON WHERE RP_NO=%s""", [RP_NO])
|
|
|
+ # 删除金额立账单
|
|
|
+ cursor.execute("""DELETE FROM MF_MON WHERE RP_NO=%s""", [RP_NO])
|
|
|
+ #删除账户收支单表头
|
|
|
+ cursor.execute("""DELETE FROM MF_BAC WHERE BB_NO=%s""", ['BT'+RP_NO[2::]])
|
|
|
+ #删除账户收支单表身
|
|
|
+ cursor.execute("""DELETE FROM TF_BAC WHERE BB_NO=%s""", ['BT'+RP_NO[2::]])
|
|
|
+ except Exception:
|
|
|
+ transaction.savepoint_rollback(sid)
|
|
|
+ return http.HttpResponseForbidden("预计付款单修改sql语句执行异常")
|
|
|
+ transaction.savepoint_commit(sid)
|
|
|
context = {
|
|
|
'a': 'delete预付款作业'
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
|
|
|
+
|
|
|
#预付冲应付
|
|
|
class ExpectedPtOperationView(View):
|
|
|
|
|
@@ -536,6 +579,7 @@ class ExpectedPtOperationView(View):
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
|
|
|
+ @transaction.atomic
|
|
|
def post(self, request):
|
|
|
|
|
|
req_data = json.loads(request.body.decode())
|
|
@@ -552,10 +596,9 @@ class ExpectedPtOperationView(View):
|
|
|
# print(list[0])
|
|
|
|
|
|
# 判断单号是否存在
|
|
|
- row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO)
|
|
|
+ row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO,'RP_ID','2')
|
|
|
if row_ZL_NO > 0:
|
|
|
- return http.HttpResponseForbidden('单号重复')
|
|
|
-
|
|
|
+ return http.HttpResponseForbidden('预付款冲应付单据号码已存在')
|
|
|
# 获取总金额
|
|
|
sum_ATM = 0 # 冲款金额
|
|
|
yf_sum = 0 # 获取单据应付款总金额
|
|
@@ -568,88 +611,92 @@ class ExpectedPtOperationView(View):
|
|
|
return http.HttpResponseForbidden('冲款金额大于应付金额')
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
- # 插入回冲预付款扣款表
|
|
|
- # cursor.execute("SELECT COUNT(*) FROM CUST WHERE CUS_NO=%s", [CUS_NO])
|
|
|
- cursor.execute("""INSERT INTO TF_MON1(RP_ID,RP_NO,ITM,IRP_NO,RP_ID1,IRPITM,IRPITM2,AMTN_CLS)VALUES
|
|
|
- (2,%s,1,%s,2,1,0,%s)""", [RP_NO,IRP_NO,sum_ATM])
|
|
|
- # RP_NO 付款单号 RP_NO
|
|
|
- # IRP_NO 预付款单号 IRP_NO
|
|
|
- # AMTN_CLS 付款总金额 sum_ATM
|
|
|
-
|
|
|
- # 插入付款单表头
|
|
|
- cursor.execute("""INSERT INTO TF_MON(IRP_ID,RP_NO,ITM,RP_ID,CLS_ID,RP_DD,CUS_NO,INCLUDESON,AMTN_CLS,AMTN_IRP,EXC_RTO,DEP,USR,CHK_MAN,CLS_DATE,SYS_DATE,IEA_ID,IOR_ID,SK_TYPE)VALUES
|
|
|
- ('F',%s,1,2,'F',%s,%s,'F',%s,%s,1,'0000',%s,%s,%s,%s,'F','F',1)""",
|
|
|
- [RP_NO,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CUS_NO,sum_ATM,sum_ATM,USR,USR,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),datetime.datetime.strptime(RP_DD, '%Y-%m-%d')])
|
|
|
- # RP_NO 付款单 RP_NO
|
|
|
- # RP_DD 付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # CUS_NO 付款厂商 CUS_NO
|
|
|
- # AMTN_CLS 付款金额 sum_ATM
|
|
|
- # AMTN_IRP 金额 sum_ATM
|
|
|
- # USR 制单人 USR
|
|
|
- # CHK_MAN 审核人 USR
|
|
|
- # CLS_DATE 制单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # SYS_DATE 审核时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
-
|
|
|
- # 插入付款单表身,先遍历出每一项的单号和金额,然后在插入
|
|
|
- itm=0 #定义项次
|
|
|
- for i in list:
|
|
|
- itm +=1
|
|
|
- print(i["DH"],i["ATM"]) #得到单号和金额
|
|
|
- print(itm)
|
|
|
- cursor.execute("""INSERT INTO TC_MON(RP_ID,RP_NO,ITM,ITM2,ARP_NO,AMTN_CLS,ARP_OPN_ID,RP_DD,CUS_NO,PRE_ITM)values
|
|
|
- (2,%s,1,%s,%s,%s,2,%s,%s,%s)""", [RP_NO,itm,'AP'+i["DH"][2::],i["ATM"],datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CUS_NO,itm])
|
|
|
- # RP_NO 付款单号 RP_NO
|
|
|
- # ITM2 项次 itm
|
|
|
- # ARP_NO 立账单号 'AP'+i["DH"][2::]
|
|
|
- # AMTN_CLS 冲款金额 i["ATM"]
|
|
|
- # RP_DD 冲款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # CUS_NO 客户 CUS_NO
|
|
|
- # PRE_ITM 项次 itm
|
|
|
-
|
|
|
- # 更新立账金额
|
|
|
- # 回写立账单的数据
|
|
|
- # cursor.execute(
|
|
|
- # """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s WHERE BIL_NO=%s""",
|
|
|
- # [i["ATM"],i["ATM"], i["DH"]])
|
|
|
-
|
|
|
- cursor.execute(
|
|
|
- """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s WHERE BIL_NO=%s""",
|
|
|
- [i["ATM"],i["ATM"], i["DH"]])
|
|
|
|
|
|
- # cursor.execute(
|
|
|
- # """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s,AMT=ISNULL(AMT,0)-ISNULL(AMTN_RCV,0)-%s WHERE BIL_NO=%s""",
|
|
|
- # [AMTN_BC, AMTN_BC, MF_LZ1])
|
|
|
- # AMTN_RCV 已冲金额 ISNULL(AMTN_RCV,0)+%s
|
|
|
- # AMT 未冲金额 ISNULL(AMT,0)-%s
|
|
|
- # BIL_NO 开票单号
|
|
|
-
|
|
|
- # 如果单据已经冲完,结案掉立账单,还有进货的立账结案标识
|
|
|
- row_AMT = cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s",
|
|
|
- [i["DH"]]).fetchall()[0][0]
|
|
|
- if row_AMT <= 0:
|
|
|
- cursor.execute("""UPDATE MF_ARP SET CLOSE_ID='T' WHERE BIL_NO=%s""", [i["DH"]])
|
|
|
- cursor.execute("""UPDATE MF_PSS SET LZ_CLS_ID='T',CLSLZ='T' WHERE PS_NO=%s""", ['PC' + i["DH"][2::]])
|
|
|
- print(1)
|
|
|
- # 插入预付款已冲金额表 ------
|
|
|
- cursor.execute(
|
|
|
- """INSERT INTO MF_MON(RP_NO,RP_DD,RP_ID,DEP,AMTN,AMTN_ARP,AMTN_REST,FJ_NUM)VALUES(%s,%s,2,'0000',0,%s,%s,0)""",
|
|
|
- [RP_NO, datetime.datetime.strptime(RP_DD, '%Y-%m-%d'), yf_sum,sum_ATM])
|
|
|
- # RP_NO 单号 RP_NO
|
|
|
- # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # AMTN_ARP 表身总金额 yf_sum
|
|
|
- # AMTN_REST 本次冲款总金额 sum_ATM
|
|
|
- print(2)
|
|
|
- # 更新预付款单已付金额
|
|
|
- cursor.execute(
|
|
|
- """UPDATE TF_MON SET AMTN_CLS=ISNULL(AMTN_CLS,0)+%s WHERE RP_NO=%s""",
|
|
|
- [sum_ATM,IRP_NO])
|
|
|
-
|
|
|
- # 获取预付款单的预付金额和已冲金额,进行对比,如果两个值相同,那么就结案掉预付款单
|
|
|
- row_AMTN_MF_MON = cursor.execute(
|
|
|
- """SELECT ISNULL(AMTN_BC,0) AS AMTN_BC, ISNULL(AMTN_CLS,0) AS AMTN_CLS FROM TF_MON WHERE RP_NO=%s""",[IRP_NO]).fetchall()
|
|
|
- if float(row_AMTN_MF_MON[0][0]) == float(row_AMTN_MF_MON[0][1]):
|
|
|
- cursor.execute("""UPDATE TF_MON SET CLS_ID='T' WHERE IRP_NO=%s""",[IRP_NO])
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
+ try:
|
|
|
+ # 插入回冲预付款扣款表
|
|
|
+ # cursor.execute("SELECT COUNT(*) FROM CUST WHERE CUS_NO=%s", [CUS_NO])
|
|
|
+ cursor.execute("""INSERT INTO TF_MON1(RP_ID,RP_NO,ITM,IRP_NO,RP_ID1,IRPITM,IRPITM2,AMTN_CLS)VALUES
|
|
|
+ (2,%s,1,%s,2,1,0,%s)""", [RP_NO,IRP_NO,sum_ATM])
|
|
|
+ # RP_NO 付款单号 RP_NO
|
|
|
+ # IRP_NO 预付款单号 IRP_NO
|
|
|
+ # AMTN_CLS 付款总金额 sum_ATM
|
|
|
+
|
|
|
+ # 插入付款单表头
|
|
|
+ cursor.execute("""INSERT INTO TF_MON(IRP_ID,RP_NO,ITM,RP_ID,CLS_ID,RP_DD,CUS_NO,INCLUDESON,AMTN_CLS,AMTN_IRP,EXC_RTO,DEP,USR,CHK_MAN,CLS_DATE,SYS_DATE,IEA_ID,IOR_ID,SK_TYPE)VALUES
|
|
|
+ ('F',%s,1,2,'F',%s,%s,'F',%s,%s,1,'0000',%s,%s,%s,%s,'F','F',1)""",
|
|
|
+ [RP_NO,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CUS_NO,sum_ATM,sum_ATM,USR,USR,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),datetime.datetime.strptime(RP_DD, '%Y-%m-%d')])
|
|
|
+ # RP_NO 付款单 RP_NO
|
|
|
+ # RP_DD 付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # CUS_NO 付款厂商 CUS_NO
|
|
|
+ # AMTN_CLS 付款金额 sum_ATM
|
|
|
+ # AMTN_IRP 金额 sum_ATM
|
|
|
+ # USR 制单人 USR
|
|
|
+ # CHK_MAN 审核人 USR
|
|
|
+ # CLS_DATE 制单时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # SYS_DATE 审核时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+
|
|
|
+ # 插入付款单表身,先遍历出每一项的单号和金额,然后在插入
|
|
|
+ itm=0 #定义项次
|
|
|
+ for i in list:
|
|
|
+ itm +=1
|
|
|
+ print(i["DH"],i["ATM"]) #得到单号和金额
|
|
|
+ print(itm)
|
|
|
+ cursor.execute("""INSERT INTO TC_MON(RP_ID,RP_NO,ITM,ITM2,ARP_NO,AMTN_CLS,ARP_OPN_ID,RP_DD,CUS_NO,PRE_ITM)values
|
|
|
+ (2,%s,1,%s,%s,%s,2,%s,%s,%s)""", [RP_NO,itm,'AP'+i["DH"][2::],i["ATM"],datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CUS_NO,itm])
|
|
|
+ # RP_NO 付款单号 RP_NO
|
|
|
+ # ITM2 项次 itm
|
|
|
+ # ARP_NO 立账单号 'AP'+i["DH"][2::]
|
|
|
+ # AMTN_CLS 冲款金额 i["ATM"]
|
|
|
+ # RP_DD 冲款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # CUS_NO 客户 CUS_NO
|
|
|
+ # PRE_ITM 项次 itm
|
|
|
+
|
|
|
+ # 更新立账金额
|
|
|
+ # 回写立账单的数据
|
|
|
+ # cursor.execute(
|
|
|
+ # """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s WHERE BIL_NO=%s""",
|
|
|
+ # [i["ATM"],i["ATM"], i["DH"]])
|
|
|
|
|
|
+ cursor.execute(
|
|
|
+ """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s WHERE BIL_NO=%s""",
|
|
|
+ [i["ATM"],i["ATM"], i["DH"]])
|
|
|
+
|
|
|
+ # cursor.execute(
|
|
|
+ # """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s,AMT=ISNULL(AMT,0)-ISNULL(AMTN_RCV,0)-%s WHERE BIL_NO=%s""",
|
|
|
+ # [AMTN_BC, AMTN_BC, MF_LZ1])
|
|
|
+ # AMTN_RCV 已冲金额 ISNULL(AMTN_RCV,0)+%s
|
|
|
+ # AMT 未冲金额 ISNULL(AMT,0)-%s
|
|
|
+ # BIL_NO 开票单号
|
|
|
+
|
|
|
+ # 如果单据已经冲完,结案掉立账单,还有进货的立账结案标识
|
|
|
+ row_AMT = cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s",
|
|
|
+ [i["DH"]]).fetchall()[0][0]
|
|
|
+ if row_AMT <= 0:
|
|
|
+ cursor.execute("""UPDATE MF_ARP SET CLOSE_ID='T' WHERE BIL_NO=%s""", [i["DH"]])
|
|
|
+ cursor.execute("""UPDATE MF_PSS SET LZ_CLS_ID='T',CLSLZ='T' WHERE PS_NO=%s AND PS_ID='PC'""", ['PC' + i["DH"][2::]])
|
|
|
+ # 插入预付款已冲金额表 ------
|
|
|
+ cursor.execute(
|
|
|
+ """INSERT INTO MF_MON(RP_NO,RP_DD,RP_ID,DEP,AMTN,AMTN_ARP,AMTN_REST,FJ_NUM)VALUES(%s,%s,2,'0000',0,%s,%s,0)""",
|
|
|
+ [RP_NO, datetime.datetime.strptime(RP_DD, '%Y-%m-%d'), yf_sum,sum_ATM])
|
|
|
+ # RP_NO 单号 RP_NO
|
|
|
+ # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # AMTN_ARP 表身总金额 yf_sum
|
|
|
+ # AMTN_REST 本次冲款总金额 sum_ATM
|
|
|
+ # 更新预付款单已付金额
|
|
|
+ cursor.execute(
|
|
|
+ """UPDATE TF_MON SET AMTN_CLS=ISNULL(AMTN_CLS,0)+%s WHERE RP_NO=%s AND RP_ID='2'""",
|
|
|
+ [sum_ATM,IRP_NO])
|
|
|
+
|
|
|
+ # 获取预付款单的预付金额和已冲金额,进行对比,如果两个值相同,那么就结案掉预付款单
|
|
|
+ row_AMTN_MF_MON = cursor.execute(
|
|
|
+ """SELECT ISNULL(AMTN_BC,0) AS AMTN_BC, ISNULL(AMTN_CLS,0) AS AMTN_CLS FROM TF_MON WHERE RP_NO=%s AND RP_ID='2'""",[IRP_NO]).fetchall()
|
|
|
+ if float(row_AMTN_MF_MON[0][0]) == float(row_AMTN_MF_MON[0][1]):
|
|
|
+ cursor.execute("""UPDATE TF_MON SET CLS_ID='T' WHERE IRP_NO=%s AND RP_ID='2'""",[IRP_NO])
|
|
|
+ except Exception:
|
|
|
+ transaction.savepoint_rollback(sid)
|
|
|
+ return http.HttpResponseForbidden("预计冲应该付作业新增单据sql语句执行异常")
|
|
|
+ transaction.savepoint_commit(sid)
|
|
|
a = {
|
|
|
"RP_NO": "PT9A230002",
|
|
|
"IRP_NO": "PT9A220001",
|
|
@@ -670,6 +717,7 @@ class ExpectedPtOperationView(View):
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
|
|
|
+ @transaction.atomic
|
|
|
def put(self, request):
|
|
|
req_data = json.loads(request.body.decode())
|
|
|
# # 获取参数
|
|
@@ -679,9 +727,9 @@ class ExpectedPtOperationView(View):
|
|
|
list = req_data.get("list") # 付款单号 字符类型
|
|
|
UP_DD = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # 修改时间
|
|
|
# 判断单号是否存在
|
|
|
- row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO)
|
|
|
+ row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO,'RP_ID','2')
|
|
|
if row_ZL_NO <= 0:
|
|
|
- return http.HttpResponseForbidden('单号不存在')
|
|
|
+ return http.HttpResponseForbidden('付款单不存在')
|
|
|
|
|
|
# 获取总金额
|
|
|
sum_ATM = 0 # 冲款金额
|
|
@@ -696,81 +744,89 @@ class ExpectedPtOperationView(View):
|
|
|
return http.HttpResponseForbidden('冲款金额大于应付金额')
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
- # 修改回冲预付款扣款表
|
|
|
- cursor.execute("""UPDATE TF_MON1 SET AMTN_CLS=%s WHERE RP_NO=%s""", [sum_ATM, RP_NO])
|
|
|
- # RP_NO 付款单号 RP_NO
|
|
|
- # IRP_NO 预付款单号 IRP_NO
|
|
|
- # AMTN_CLS 付款总金额 sum_ATM
|
|
|
-
|
|
|
- # 修改付款单表头
|
|
|
- cursor.execute("""UPDATE TF_MON SET RP_DD=%s,AMTN_CLS=%s,AMTN_IRP=%s,MODIFY_DD=%s,MODIFY_MAN=USR WHERE RP_NO=%s""",
|
|
|
- [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),sum_ATM,sum_ATM,UP_DD,RP_NO])
|
|
|
- # RP_NO 付款单 RP_NO
|
|
|
- # RP_DD 付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # CUS_NO 付款厂商 CUS_NO
|
|
|
- # AMTN_CLS 付款金额 sum_ATM
|
|
|
- # AMTN_IRP 金额 sum_ATM
|
|
|
- # 修改付款单表身,先遍历出每一项的单号和金额,然后在插入
|
|
|
- itm = 0 # 定义项次
|
|
|
- YD_ATY = 0 #原来单总金额
|
|
|
- for i in list:
|
|
|
- itm += 1
|
|
|
- print(i["DH"], i["ATM"]) # 得到单号和金额
|
|
|
- QTY_TC_MON=cursor.execute("""SELECT ISNULL(AMTN_CLS,0) FROM TC_MON WHERE ARP_NO=%s""", ['AP'+i["DH"][2::]]).fetchall()[0][0]
|
|
|
- YD_ATY = round((YD_ATY + QTY_TC_MON),4)
|
|
|
- print(i["ATM"])
|
|
|
- cursor.execute("""UPDATE TC_MON SET AMTN_CLS=%s WHERE ARP_NO=%s""", [i["ATM"],'AP'+i["DH"][2::]])
|
|
|
-
|
|
|
- # RP_NO 付款单号 RP_NO
|
|
|
- # ITM2 项次 itm
|
|
|
- # ARP_NO 立账单号 'AP'+i["DH"][2::]
|
|
|
- # AMTN_CLS 冲款金额 i["ATM"]
|
|
|
- # RP_DD 冲款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # CUS_NO 客户 CUS_NO
|
|
|
- # PRE_ITM 项次 itm
|
|
|
-
|
|
|
- # 更新立账金额
|
|
|
- # 回写立账单的数据
|
|
|
- # 获取原单已冲金额未冲金额
|
|
|
- #AMTN_RCV 已经冲金额 AMT未冲金额========================================================================================
|
|
|
- ATM_MF_ARP=cursor.execute("""SELECT ISNULL(AMTN_RCV,0),ISNULL(AMT,0) FROM MF_ARP WHERE BIL_NO=%s""",[ i["DH"]]).fetchall()
|
|
|
- AMTN_RCV=ATM_MF_ARP[0][0] #原单已经冲金额
|
|
|
- AMT=ATM_MF_ARP[0][1] #原单未冲金额
|
|
|
+
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
+ try:
|
|
|
+ # 修改回冲预付款扣款表
|
|
|
+ cursor.execute("""UPDATE TF_MON1 SET AMTN_CLS=%s WHERE RP_NO=%s AND RP_ID='2'""", [sum_ATM, RP_NO])
|
|
|
+ # RP_NO 付款单号 RP_NO
|
|
|
+ # IRP_NO 预付款单号 IRP_NO
|
|
|
+ # AMTN_CLS 付款总金额 sum_ATM
|
|
|
+
|
|
|
+ # 修改付款单表头
|
|
|
+ cursor.execute("""UPDATE TF_MON SET RP_DD=%s,AMTN_CLS=%s,AMTN_IRP=%s,MODIFY_DD=%s,MODIFY_MAN=USR WHERE RP_NO=%s AND RP_ID='2'""",
|
|
|
+ [datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),sum_ATM,sum_ATM,UP_DD,RP_NO])
|
|
|
+ # RP_NO 付款单 RP_NO
|
|
|
+ # RP_DD 付款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # CUS_NO 付款厂商 CUS_NO
|
|
|
+ # AMTN_CLS 付款金额 sum_ATM
|
|
|
+ # AMTN_IRP 金额 sum_ATM
|
|
|
+ # 修改付款单表身,先遍历出每一项的单号和金额,然后在插入
|
|
|
+ itm = 0 # 定义项次
|
|
|
+ YD_ATY = 0 #原来单总金额
|
|
|
+ for i in list:
|
|
|
+ itm += 1
|
|
|
+ print(i["DH"], i["ATM"]) # 得到单号和金额
|
|
|
+ QTY_TC_MON=cursor.execute("""SELECT ISNULL(AMTN_CLS,0) FROM TC_MON WHERE ARP_NO=%s""", ['AP'+i["DH"][2::]]).fetchall()[0][0]
|
|
|
+ YD_ATY = round((YD_ATY + QTY_TC_MON),4)
|
|
|
+ print(i["ATM"])
|
|
|
+ cursor.execute("""UPDATE TC_MON SET AMTN_CLS=%s WHERE ARP_NO=%s AND RP_ID='2'""", [i["ATM"],'AP'+i["DH"][2::]])
|
|
|
+
|
|
|
+ # RP_NO 付款单号 RP_NO
|
|
|
+ # ITM2 项次 itm
|
|
|
+ # ARP_NO 立账单号 'AP'+i["DH"][2::]
|
|
|
+ # AMTN_CLS 冲款金额 i["ATM"]
|
|
|
+ # RP_DD 冲款日期 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # CUS_NO 客户 CUS_NO
|
|
|
+ # PRE_ITM 项次 itm
|
|
|
+
|
|
|
+ # 更新立账金额
|
|
|
+ # 回写立账单的数据
|
|
|
+ # 获取原单已冲金额未冲金额
|
|
|
+ #AMTN_RCV 已经冲金额 AMT未冲金额========================================================================================
|
|
|
+ ATM_MF_ARP=cursor.execute("""SELECT ISNULL(AMTN_RCV,0),ISNULL(AMT,0) FROM MF_ARP WHERE BIL_NO=%s""",[ i["DH"]]).fetchall()
|
|
|
+ AMTN_RCV=ATM_MF_ARP[0][0] #原单已经冲金额
|
|
|
+ AMT=ATM_MF_ARP[0][1] #原单未冲金额
|
|
|
+ cursor.execute(
|
|
|
+ """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s-%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s-%s WHERE BIL_NO=%s""",
|
|
|
+ [i["ATM"],AMTN_RCV, i["ATM"],AMT, i["DH"]])
|
|
|
+
|
|
|
+ # AMTN_RCV 已冲金额 ISNULL(AMTN_RCV,0)+%s
|
|
|
+ # AMT 未冲金额 ISNULL(AMT,0)-%s
|
|
|
+ # BIL_NO 开票单号
|
|
|
+
|
|
|
+ # 如果单据已经冲完,结案掉立账单,还有进货的立账结案标识
|
|
|
+ row_AMT = cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s",
|
|
|
+ [i["DH"]]).fetchall()[0][0]
|
|
|
+ if row_AMT <= 0:
|
|
|
+ cursor.execute("""UPDATE MF_ARP SET CLOSE_ID='F' WHERE BIL_NO=%s""", [i["DH"]])
|
|
|
+ cursor.execute("""UPDATE MF_PSS SET LZ_CLS_ID='F',CLSLZ='F' WHERE PS_NO=%s AND PS_ID='PC'""",
|
|
|
+ ['PC' + i["DH"][2::]])
|
|
|
+
|
|
|
+ # 更新预付款已冲金额表
|
|
|
+ cursor.execute("""UPDATE MF_MON SET AMTN_REST=%s WHERE RP_NO=%s AND RP_ID='2'""",[sum_ATM,RP_NO])
|
|
|
+ # RP_NO 单号 RP_NO
|
|
|
+ # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
+ # AMTN_ARP 应付总金额 yf_sum
|
|
|
+ # AMTN_REST 本次冲款总金额 sum_ATM
|
|
|
+
|
|
|
+ # 更新预付款单已付金额
|
|
|
cursor.execute(
|
|
|
- """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s-%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s-%s WHERE BIL_NO=%s""",
|
|
|
- [i["ATM"],AMTN_RCV, i["ATM"],AMT, i["DH"]])
|
|
|
+ """UPDATE TF_MON SET AMTN_CLS=ISNULL(AMTN_CLS,0)+%s-%s WHERE RP_NO=%s AND RP_ID='2'""",
|
|
|
+ [sum_ATM,YD_ATY,IRP_NO])
|
|
|
|
|
|
- # AMTN_RCV 已冲金额 ISNULL(AMTN_RCV,0)+%s
|
|
|
- # AMT 未冲金额 ISNULL(AMT,0)-%s
|
|
|
- # BIL_NO 开票单号
|
|
|
+ # 获取预付款单的预付金额和已冲金额,进行对比,如果两个值相同,那么就结案掉预付款单
|
|
|
+ row_AMTN_MF_MON = cursor.execute(
|
|
|
+ """SELECT ISNULL(AMTN_BC,0) AS AMTN_BC, ISNULL(AMTN_CLS,0) AS AMTN_CLS FROM TF_MON WHERE RP_NO=%s AND RP_ID='2'""",
|
|
|
+ [IRP_NO]).fetchall()
|
|
|
|
|
|
- # 如果单据已经冲完,结案掉立账单,还有进货的立账结案标识
|
|
|
- row_AMT = cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE BIL_NO=%s",
|
|
|
- [i["DH"]]).fetchall()[0][0]
|
|
|
- if row_AMT <= 0:
|
|
|
- cursor.execute("""UPDATE MF_ARP SET CLOSE_ID='F' WHERE BIL_NO=%s""", [i["DH"]])
|
|
|
- cursor.execute("""UPDATE MF_PSS SET LZ_CLS_ID='F',CLSLZ='F' WHERE PS_NO=%s""",
|
|
|
- ['PC' + i["DH"][2::]])
|
|
|
-
|
|
|
- # 更新预付款已冲金额表
|
|
|
- cursor.execute("""UPDATE MF_MON SET AMTN_REST=%s WHERE RP_NO=%s""",[sum_ATM,RP_NO])
|
|
|
- # RP_NO 单号 RP_NO
|
|
|
- # RP_DD 时间 datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
|
|
|
- # AMTN_ARP 应付总金额 yf_sum
|
|
|
- # AMTN_REST 本次冲款总金额 sum_ATM
|
|
|
-
|
|
|
- # 更新预付款单已付金额
|
|
|
- cursor.execute(
|
|
|
- """UPDATE TF_MON SET AMTN_CLS=ISNULL(AMTN_CLS,0)+%s-%s WHERE RP_NO=%s""",
|
|
|
- [sum_ATM,YD_ATY,IRP_NO])
|
|
|
-
|
|
|
- # 获取预付款单的预付金额和已冲金额,进行对比,如果两个值相同,那么就结案掉预付款单
|
|
|
- row_AMTN_MF_MON = cursor.execute(
|
|
|
- """SELECT ISNULL(AMTN_BC,0) AS AMTN_BC, ISNULL(AMTN_CLS,0) AS AMTN_CLS FROM TF_MON WHERE RP_NO=%s""",
|
|
|
- [IRP_NO]).fetchall()
|
|
|
-
|
|
|
- if float(row_AMTN_MF_MON[0][0]) == float(row_AMTN_MF_MON[0][1]):
|
|
|
- cursor.execute("""UPDATE TF_MON SET CLS_ID='F' WHERE IRP_NO=%s""", [IRP_NO])
|
|
|
+ if float(row_AMTN_MF_MON[0][0]) == float(row_AMTN_MF_MON[0][1]):
|
|
|
+ cursor.execute("""UPDATE TF_MON SET CLS_ID='F' WHERE IRP_NO=%s AND RP_ID='2'""", [IRP_NO])
|
|
|
+
|
|
|
+ except Exception:
|
|
|
+ transaction.savepoint_rollback(sid)
|
|
|
+ return http.HttpResponseForbidden("预计冲应该付作业修改单据sql语句执行异常")
|
|
|
+ transaction.savepoint_commit(sid)
|
|
|
a = {
|
|
|
"RP_NO": "PT9A230002",
|
|
|
"IRP_NO": "PT9A220001",
|
|
@@ -791,59 +847,63 @@ class ExpectedPtOperationView(View):
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
|
|
|
+ @transaction.atomic
|
|
|
def delete(self, request):
|
|
|
req_data = json.loads(request.body.decode())
|
|
|
# # 获取参数
|
|
|
RP_NO = req_data.get("RP_NO") # 付款单号 字符类型
|
|
|
|
|
|
# 判断单号是否存在
|
|
|
- row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO)
|
|
|
+ row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO,'RP_ID','2')
|
|
|
if row_ZL_NO <= 0:
|
|
|
return http.HttpResponseForbidden('单号不存在')
|
|
|
with connection.cursor() as cursor:
|
|
|
- # 获取原单付款单总金额用于扣减预付款单总金额
|
|
|
- sum_TF_MON=cursor.execute("""SELECT ISNULL(AMTN_CLS,0) FROM TF_MON WHERE RP_NO=%s""",[RP_NO]).fetchall()[0][0]
|
|
|
- print(round(sum_TF_MON, 4))
|
|
|
- #获取预付款单单号
|
|
|
- TF_MON_NO = cursor.execute("""SELECT IRP_NO FROM TF_MON1 WHERE RP_NO=%s""", [RP_NO]).fetchall()[0][0]
|
|
|
- print(TF_MON_NO)
|
|
|
- # 修改预付款扣款金额
|
|
|
- cursor.execute("""UPDATE TF_MON SET AMTN_CLS=ISNULL(AMTN_CLS,0)-%s WHERE RP_NO=%s""", [sum_TF_MON,TF_MON_NO])
|
|
|
- # 以列表的形式获取付款单的立账单号
|
|
|
- TC_MON_RP_NO = cursor.execute("""SELECT ARP_NO FROM TC_MON WHERE RP_NO=%s""", [RP_NO]).fetchall()
|
|
|
- # 遍历列表得到每一张立账单号
|
|
|
- for i in TC_MON_RP_NO:
|
|
|
- print(i[0]) #立账单号
|
|
|
- # 更新立账金额
|
|
|
- # 回写立账单的数据
|
|
|
- # 获取原单已冲金额未冲金额
|
|
|
- # AMTN_RCV 已经冲金额 AMT未冲金额===========================================================
|
|
|
- ATM_MF_ARP = cursor.execute("""SELECT ISNULL(AMTN_RCV,0),ISNULL(AMT,0) FROM MF_ARP WHERE ARP_NO=%s""",[i[0]]).fetchall()
|
|
|
- AMTN_RCV = ATM_MF_ARP[0][0] # 原单已经冲金额
|
|
|
- AMT = ATM_MF_ARP[0][1] # 原单未冲金额
|
|
|
- cursor.execute(
|
|
|
- """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)-%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s WHERE ARP_NO=%s""",
|
|
|
- [AMTN_RCV,AMT,i[0]])
|
|
|
-
|
|
|
- # AMTN_RCV 已冲金额 ISNULL(AMTN_RCV,0)+%s
|
|
|
- # AMT 未冲金额 ISNULL(AMT,0)-%s
|
|
|
- # BIL_NO 开票单号
|
|
|
-
|
|
|
- # 如果单据已经冲完,结案掉立账单,还有进货的立账结案标识
|
|
|
- row_AMT = cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE ARP_NO=%s",[i[0]]).fetchall()[0][0]
|
|
|
- if row_AMT <= 0:
|
|
|
- cursor.execute("""UPDATE MF_ARP SET CLOSE_ID='F' WHERE ARP_NO=%s""", [i[0]])
|
|
|
- cursor.execute("""UPDATE MF_PSS SET LZ_CLS_ID='F',CLSLZ='F' WHERE PS_NO=%s""",['PC' + i[0][2::]])
|
|
|
- # 删除扣款单
|
|
|
- cursor.execute("""DELETE FROM TF_MON1 WHERE RP_NO=%s""", [RP_NO])
|
|
|
- #删除付款单表头
|
|
|
- cursor.execute("""DELETE FROM TF_MON WHERE RP_NO=%s""", [RP_NO])
|
|
|
- #删除付款单表身
|
|
|
- cursor.execute("""DELETE FROM TC_MON WHERE RP_NO=%s""", [RP_NO])
|
|
|
- #删除付款记录
|
|
|
- cursor.execute("""DELETE FROM MF_MON WHERE RP_NO=%s""", [RP_NO])
|
|
|
-
|
|
|
|
|
|
+ sid = transaction.savepoint() # 开启事物
|
|
|
+ try:
|
|
|
+ # 获取原单付款单总金额用于扣减预付款单总金额
|
|
|
+ sum_TF_MON=cursor.execute("""SELECT ISNULL(AMTN_CLS,0) FROM TF_MON WHERE RP_NO=%s AND RP_ID='2'""",[RP_NO]).fetchall()[0][0]
|
|
|
+ #获取预付款单单号
|
|
|
+ TF_MON_NO = cursor.execute("""SELECT IRP_NO FROM TF_MON1 WHERE RP_NO=%s AND RP_ID='2'""", [RP_NO]).fetchall()[0][0]
|
|
|
+ # 修改预付款扣款金额
|
|
|
+ cursor.execute("""UPDATE TF_MON SET AMTN_CLS=ISNULL(AMTN_CLS,0)-%s WHERE RP_NO=%s AND RP_ID='2'""", [sum_TF_MON,TF_MON_NO])
|
|
|
+ # 以列表的形式获取付款单的立账单号
|
|
|
+ TC_MON_RP_NO = cursor.execute("""SELECT ARP_NO FROM TC_MON WHERE RP_NO=%s AND RP_ID='2'""", [RP_NO]).fetchall()
|
|
|
+ # 遍历列表得到每一张立账单号
|
|
|
+ for i in TC_MON_RP_NO:
|
|
|
+ print(i[0]) #立账单号
|
|
|
+ # 更新立账金额
|
|
|
+ # 回写立账单的数据
|
|
|
+ # 获取原单已冲金额未冲金额
|
|
|
+ # AMTN_RCV 已经冲金额 AMT未冲金额===========================================================
|
|
|
+ ATM_MF_ARP = cursor.execute("""SELECT ISNULL(AMTN_RCV,0),ISNULL(AMT,0) FROM MF_ARP WHERE ARP_NO=%s""",[i[0]]).fetchall()
|
|
|
+ AMTN_RCV = ATM_MF_ARP[0][0] # 原单已经冲金额
|
|
|
+ AMT = ATM_MF_ARP[0][1] # 原单未冲金额
|
|
|
+ cursor.execute(
|
|
|
+ """UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)-%s,AMT=ISNULL(AMTN,0)-ISNULL(AMTN_RCV,0)-%s WHERE ARP_NO=%s""",
|
|
|
+ [AMTN_RCV,AMT,i[0]])
|
|
|
+
|
|
|
+ # AMTN_RCV 已冲金额 ISNULL(AMTN_RCV,0)+%s
|
|
|
+ # AMT 未冲金额 ISNULL(AMT,0)-%s
|
|
|
+ # BIL_NO 开票单号
|
|
|
+
|
|
|
+ # 如果单据已经冲完,结案掉立账单,还有进货的立账结案标识
|
|
|
+ row_AMT = cursor.execute("SELECT CAST(ISNULL(AMT,0) AS INT ),BIL_NO FROM MF_ARP WHERE ARP_NO=%s",[i[0]]).fetchall()[0][0]
|
|
|
+ if row_AMT <= 0:
|
|
|
+ cursor.execute("""UPDATE MF_ARP SET CLOSE_ID='F' WHERE ARP_NO=%s""", [i[0]])
|
|
|
+ cursor.execute("""UPDATE MF_PSS SET LZ_CLS_ID='F',CLSLZ='F' WHERE PS_NO=%s""",['PC' + i[0][2::]])
|
|
|
+ # 删除扣款单
|
|
|
+ cursor.execute("""DELETE FROM TF_MON1 WHERE RP_NO=%s RP_ID='2'""", [RP_NO])
|
|
|
+ #删除付款单表头
|
|
|
+ cursor.execute("""DELETE FROM TF_MON WHERE RP_NO=%s RP_ID='2'""", [RP_NO])
|
|
|
+ #删除付款单表身
|
|
|
+ cursor.execute("""DELETE FROM TC_MON WHERE RP_NO=%s RP_ID='2'""", [RP_NO])
|
|
|
+ #删除付款记录
|
|
|
+ cursor.execute("""DELETE FROM MF_MON WHERE RP_NO=%s RP_ID='2'""", [RP_NO])
|
|
|
+ except Exception:
|
|
|
+ transaction.savepoint_rollback(sid)
|
|
|
+ return http.HttpResponseForbidden("预计冲应该付作业修改单据sql语句执行异常")
|
|
|
+ transaction.savepoint_commit(sid)
|
|
|
context = {
|
|
|
'a': 'delete预付冲应付作业'
|
|
|
}
|