|
@@ -10,6 +10,7 @@ import datetime
|
|
|
|
|
|
from utils.cust_data import customer_data
|
|
|
from utils.examine_ood import examine_ood
|
|
|
+from utils.invoice_dh import invoice_dh
|
|
|
from utils.usr_data import usr_data
|
|
|
|
|
|
|
|
@@ -26,13 +27,14 @@ class InvoiceView(View):
|
|
|
'a':123
|
|
|
}
|
|
|
return http.JsonResponse(context)
|
|
|
+
|
|
|
def post(self,request):
|
|
|
#1,获取参数
|
|
|
ZL_NO = request.POST.get("ZL_NO") #单据号码 1 字符型
|
|
|
LZ_DD = request.POST.get("LZ_DD") #单据日期 1 字符型
|
|
|
INV_NO = request.POST.get("INV_NO") #发票号码 1 字符型
|
|
|
INV_DD = request.POST.get("INV_DD") #发票日期 1 字符型
|
|
|
- ZHANG_ID = request.POST.get("ZHANG_ID") #立账方式 1 字符型
|
|
|
+ ZHANG_ID = request.POST.get("ZHANG_ID") #立账方式 1 字符型 2开票 1直接立账
|
|
|
TAX_ID = request.POST.get("TAX_ID") #扣税类别 1 字符型
|
|
|
AMT = request.POST.get("AMT") #开票金额 1 数字型
|
|
|
CUS_NO = request.POST.get("CUS_NO") #开票客户编码 1 字符型
|
|
@@ -63,10 +65,22 @@ class InvoiceView(View):
|
|
|
print(USR) #制单人编码 1
|
|
|
print(USR_NAME) #制单人姓名 1
|
|
|
|
|
|
- # 判断单号是否存在
|
|
|
- row_ZL_NO = examine_ood('MF_LZ1','LZ_NO',ZL_NO)
|
|
|
- if row_ZL_NO > 0:
|
|
|
- return http.HttpResponseForbidden('单号重复')
|
|
|
+ # 判断立账方式是否有效
|
|
|
+ if int(ZHANG_ID) != 1 and int(ZHANG_ID) != 2:
|
|
|
+ return http.HttpResponseForbidden('立账方式只能是1(开票),2(不开票)')
|
|
|
+
|
|
|
+ # 判断进货单号是存在
|
|
|
+ PS_NO='PC' + ZL_NO[2::]
|
|
|
+ if int(ZHANG_ID) == 1:
|
|
|
+ row_ZL_NO = examine_ood('MF_PSS', 'PS_NO', PS_NO,'PS_ID','PC')
|
|
|
+ if row_ZL_NO > 0:
|
|
|
+ return http.HttpResponseForbidden('进货单号已存在')
|
|
|
+
|
|
|
+ # 判断开票单号是否存在
|
|
|
+ if int(ZHANG_ID) > 2:
|
|
|
+ row_ZL_NO = examine_ood('MF_LZ1', 'LZ_NO', ZL_NO,'LZ_ID','LP')
|
|
|
+ if row_ZL_NO > 0:
|
|
|
+ return http.HttpResponseForbidden('开票单号已存在')
|
|
|
|
|
|
#判断客户资料是否存在,不存在则创建
|
|
|
row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2',datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'))
|
|
@@ -75,8 +89,8 @@ class InvoiceView(View):
|
|
|
row_usr = usr_data(USR,USR_NAME,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'))
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
- #判断是否开票开票
|
|
|
- if int(ZHANG_ID) == 3:
|
|
|
+ #直接开发票
|
|
|
+ if int(ZHANG_ID) == 2:
|
|
|
# 插入进货单表头-----------------------改CUR_ID RMB
|
|
|
cursor.execute("""INSERT INTO MF_PSS(PS_ID,PS_NO,PS_DD,CUS_NO,ZHANG_ID,USR,CHK_MAN,CLS_DATE,SYS_DATE,AMT,EXC_RTO,LZ_CLS_ID,CLSLZ,TAX_ID)
|
|
|
VALUES('PC',%s,%s,%s,3,%s,%s,%s,%s,%s,
|
|
@@ -110,6 +124,25 @@ class InvoiceView(View):
|
|
|
|
|
|
#开完发票回写进货单表身已开金额
|
|
|
cursor.execute("""UPDATE TF_PSS SET AMT_FP=%s,AMTN_NET_FP=%s WHERE PS_NO=%s""", [AMT,AMT,'PC'+ZL_NO[2::]])
|
|
|
+ # 不开发票直接产生进货单,并且立账
|
|
|
+ if int(ZHANG_ID) == 1:
|
|
|
+ # 插入进货单表头-----------------------改CUR_ID RMB
|
|
|
+ cursor.execute("""INSERT INTO MF_PSS(PS_ID,PS_NO,PS_DD,CUS_NO,ZHANG_ID,USR,CHK_MAN,CLS_DATE,SYS_DATE,AMT,EXC_RTO,LZ_CLS_ID,CLSLZ,TAX_ID,ARP_NO)
|
|
|
+ VALUES('PC',%s,%s,%s,1,%s,%s,%s,%s,%s,
|
|
|
+ 1,'F','F',1,%s)""",
|
|
|
+ ['PC' + ZL_NO[2::], datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), CUS_NO, USR, USR,
|
|
|
+ datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),
|
|
|
+ datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), AMT,'AP' + ZL_NO[2::]])
|
|
|
+ # 插入进货单表身
|
|
|
+ cursor.execute("""INSERT INTO TF_PSS(PS_ID,PS_NO,PS_DD,WH,PRD_NO,QTY,UP,AMT,AMTN_NET,TAX_RTO,ITM,UNIT,CSTN_SAL,PRE_ITM)
|
|
|
+ VALUES('PC',%s,%s,'0000','AQ001',1,%s,%s,%s,5,1,1,%s,1)""",
|
|
|
+ ['PC' + ZL_NO[2::], datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), AMT, AMT, AMT, AMT])
|
|
|
+ # 插入立账单MF_MRP------------------改CUR_ID RMB
|
|
|
+ cursor.execute("""INSERT INTO MF_ARP(ARP_ID,OPN_ID,ARP_NO,BIL_NO,CUS_NO,PAY_DD,INV_NO,AMT,AMTN,AMTN_NET,EXC_RTO,CLOSE_ID,BIL_ID,SYS_DATE,BIL_DD)VALUES
|
|
|
+ (2,2,%s,%s,%s,%s,%s,%s,%s,%s,1,'F','PC',%s,%s)""",
|
|
|
+ ['AP' + ZL_NO[2::], 'PC' + ZL_NO[2::], CUS_NO, datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), INV_NO
|
|
|
+ , AMT, AMT, AMT, datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),
|
|
|
+ datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')])
|
|
|
context = {
|
|
|
'a': 'POST提交'
|
|
|
}
|
|
@@ -137,6 +170,7 @@ class InvoiceView(View):
|
|
|
USR_NAME = req_data.get("USR_NAME") # 制单人姓名 1
|
|
|
SAL_ID_CODE = req_data.get("SAL_ID_CODE") # 开户银行账号 1
|
|
|
REM = req_data.get("REM") # 发票备注 1
|
|
|
+ UP_DD = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # 修改时间
|
|
|
|
|
|
# {
|
|
|
# "ZL_NO": "LP9A170002",
|
|
@@ -157,11 +191,19 @@ class InvoiceView(View):
|
|
|
# "SAL_ID_CODE": "43112919941002",
|
|
|
# "REM": "我的备注",
|
|
|
# }
|
|
|
- # 判断单号是否存在
|
|
|
- row_ZL_NO = examine_ood('MF_LZ1', 'LZ_NO', ZL_NO)
|
|
|
- if row_ZL_NO == 0:
|
|
|
- return http.HttpResponseForbidden('单号不存在')
|
|
|
-
|
|
|
+ # 判断立账方式是否有效
|
|
|
+ if int(ZHANG_ID) != 1 and int(ZHANG_ID) != 2:
|
|
|
+ return http.HttpResponseForbidden('立账方式只能是1(开票),2(不开票)')
|
|
|
+ # 判断进货单号是存在
|
|
|
+ if int(ZHANG_ID) == 1:
|
|
|
+ row_ZL_NO = examine_ood('MF_PSS', 'PS_NO', 'PC' + ZL_NO[2::],'PS_ID','PC')
|
|
|
+ if row_ZL_NO <= 0:
|
|
|
+ return http.HttpResponseForbidden('进货单号不存在')
|
|
|
+ # 判断开票单号是否存在
|
|
|
+ if int(ZHANG_ID) > 2:
|
|
|
+ row_ZL_NO = examine_ood('MF_LZ1', 'LZ_NO', ZL_NO,'LZ_ID','LP')
|
|
|
+ if row_ZL_NO <= 0:
|
|
|
+ return http.HttpResponseForbidden('开票单号不存在')
|
|
|
#判断厂商是否存在,不存在则自动创建
|
|
|
row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2',datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'))
|
|
|
|
|
@@ -169,89 +211,91 @@ class InvoiceView(View):
|
|
|
row_usr = usr_data(USR, USR_NAME,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'))
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
- # 修改进货单表头
|
|
|
- # PS_NO 单号 单号不能改用作条件
|
|
|
- # PS_DD 日期
|
|
|
- # CUS_NO 客户编码
|
|
|
- # ZHANG_ID 立账方式
|
|
|
- # USR 用户
|
|
|
- # CHK_MAN 审核人
|
|
|
- # AMT 金额
|
|
|
- cursor.execute("""UPDATE MF_PSS SET PS_DD=%s,CUS_NO=%s,ZHANG_ID=%s,AMT=%s WHERE PS_NO=%s""", [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), CUS_NO,ZHANG_ID,AMT,'PC'+ZL_NO[2::]])
|
|
|
-
|
|
|
- # 修改进货单表身
|
|
|
- # PS_DD日期
|
|
|
- #UP 单价
|
|
|
- #AMT 金额
|
|
|
- # AMTN_NET 金额
|
|
|
- # CSTN_SAL 立账金额
|
|
|
- cursor.execute("""UPDATE TF_PSS SET PS_DD=%s,UP=%s,AMTN_NET=%s,CSTN_SAL=%s,AMT=%s WHERE PS_NO=%s""", [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), AMT,AMT,AMT,AMT,'PC'+ZL_NO[2::]])
|
|
|
-
|
|
|
- # 修改发票记录
|
|
|
- cursor.execute("""UPDATE INV_NO SET INV_NO=%s,CUS_NO=%s,TITLE_BUY=%s,TITLE_PAY=%s,AMT=%s,INV_DD=%s,UNI_NO_PAY=%s,SAL_ADR=%s,SAL_TEL=%s,SAL_KH_BANK=%s,SAL_ID_CODE=%s,REM=%s WHERE BIL_NO=%s""",
|
|
|
- [INV_NO, CUS_NO,CUS_NO_NAME,CUS_NO_NAME,AMT,INV_DD,UNI_NO_PAY,SAL_ADR,SAL_TEL,SAL_KH_BANK,SAL_ID_CODE,REM,ZL_NO])
|
|
|
- # BIL_NO 开票单号 ZL_NO
|
|
|
- # INV_NO 开票号码 INV_NO
|
|
|
- # CUS_NO 开票客户编码 CUS_NO
|
|
|
- # TITLE_BUY 客户名 CUS_NO_NAME
|
|
|
- # TITLE_PAY 客户名 CUS_NO_NAME
|
|
|
- # AMT 金额 AMT
|
|
|
- #INV_DD 日期 INV_DD
|
|
|
- #UNI_NO_PAY UNI_NO_PAY
|
|
|
- # SAL_ADR SAL_ADR
|
|
|
- #SAL_TEL SAL_TEL
|
|
|
- # SAL_KH_BANK SAL_KH_BANK
|
|
|
- # SAL_ID_CODE SAL_ID_CODE
|
|
|
- #REM REM
|
|
|
-
|
|
|
- # 修改立账单MF_MRP
|
|
|
- cursor.execute("""UPDATE MF_ARP SET CUS_NO=%s,PAY_DD=%s,INV_NO=%s,AMT=%s,AMTN=%s,AMTN_NET=%s,SYS_DATE=%s WHERE ARP_NO=%s""", [CUS_NO, datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),
|
|
|
- INV_NO,AMT,AMT,AMT,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),'AP' + ZL_NO[2::]])
|
|
|
- # ARP_NO 立账单号 'AP' + ZL_NO[2::]
|
|
|
- # CUS_NO 客户代号 CUS_NO
|
|
|
- # PAY_DD 立账日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
- #INV_NO 发票号码 INV_NO
|
|
|
- # AMT 金额 AMT
|
|
|
- # AMTN AMT
|
|
|
- # AMTN_NET AMT
|
|
|
- # SYS_DATE 录入日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
-
|
|
|
- # 插入进货开票表头
|
|
|
- cursor.execute("""UPDATE MF_LZ1 SET PAY_DD=%s,LZ_DD=%s,CUS_NO=%s,INV_NO=%s,AMT=%s,AMTN_NET=%s WHERE LZ_NO=%s """,
|
|
|
- [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),CUS_NO,INV_NO,AMT,AMT,ZL_NO])
|
|
|
- # LZ_NO 单号 ZL_NO
|
|
|
- # PAY_DD 日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
- # LZ_DD 日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
- # CUS_NO 客户编码 CUS_NO
|
|
|
- # INV_NO 发票号码 INV_NO
|
|
|
- # AMT 金额 AMT
|
|
|
- # AMTN_NET 金额 AMT
|
|
|
-
|
|
|
- # 修改进货开票表身
|
|
|
- cursor.execute("""UPDATE TF_LZ1 SET AMT=%s,AMTN_NET=%s,CUS_NO=%s WHERE LZ_NO=%s""", [AMT, AMT,CUS_NO,ZL_NO])
|
|
|
- # LZ_NO 单号 ZL_NO
|
|
|
- # AMT 金额 AMT
|
|
|
- # AMTN_NET 金额 AMT
|
|
|
- # CUS_NO 客户 CUS_NO
|
|
|
- # 修改开完发票回写进货单表身已开金额
|
|
|
- cursor.execute("""UPDATE TF_PSS SET AMT_FP=%s,AMTN_NET_FP=%s WHERE PS_NO=%s""",[AMT, AMT, 'PC' + ZL_NO[2::]])
|
|
|
- print(ZL_NO)
|
|
|
- print(LZ_DD)
|
|
|
- print(INV_NO)
|
|
|
- print(INV_DD)
|
|
|
- print(ZHANG_ID)
|
|
|
- print(TAX_ID)
|
|
|
- print(AMT)
|
|
|
- print(CUS_NO)
|
|
|
- print(CUS_NO_NAME)
|
|
|
- print(UNI_NO_PAY)
|
|
|
- print(SAL_ADR)
|
|
|
- print(SAL_TEL)
|
|
|
- print(SAL_KH_BANK)
|
|
|
- print(USR)
|
|
|
- print(USR_NAME)
|
|
|
- print(SAL_ID_CODE)
|
|
|
- print(REM)
|
|
|
+ #进货开票
|
|
|
+ if int(ZHANG_ID)==2:
|
|
|
+ # 修改进货单表头
|
|
|
+ # PS_NO 单号 单号不能改用作条件
|
|
|
+ # PS_DD 日期
|
|
|
+ # CUS_NO 客户编码
|
|
|
+ # ZHANG_ID 立账方式
|
|
|
+ # USR 用户
|
|
|
+ # CHK_MAN 审核人
|
|
|
+ # AMT 金额
|
|
|
+ cursor.execute("""UPDATE MF_PSS SET PS_DD=%s,CUS_NO=%s,ZHANG_ID=%s,AMT=%s,MODIFY_DD=%s,MODIFY_MAN=USR WHERE PS_NO=%s AND PS_ID='PC'""", [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), CUS_NO,ZHANG_ID,AMT,UP_DD,'PC'+ZL_NO[2::]])
|
|
|
+
|
|
|
+ # 修改进货单表身
|
|
|
+ # PS_DD日期
|
|
|
+ #UP 单价
|
|
|
+ #AMT 金额
|
|
|
+ # AMTN_NET 金额
|
|
|
+ # CSTN_SAL 立账金额
|
|
|
+ cursor.execute("""UPDATE TF_PSS SET PS_DD=%s,UP=%s,AMTN_NET=%s,CSTN_SAL=%s,AMT=%s,AMT_FP=%s,AMTN_NET_FP=%s WHERE PS_NO=%s AND PS_ID='PC'""", [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), AMT,AMT,AMT,AMT,AMT, AMT,'PC'+ZL_NO[2::]])
|
|
|
+
|
|
|
+ # 修改发票记录
|
|
|
+ cursor.execute("""UPDATE INV_NO SET INV_NO=%s,CUS_NO=%s,TITLE_BUY=%s,TITLE_PAY=%s,AMT=%s,INV_DD=%s,UNI_NO_PAY=%s,SAL_ADR=%s,SAL_TEL=%s,SAL_KH_BANK=%s,SAL_ID_CODE=%s,REM=%s WHERE BIL_NO=%s AND BIL_ID='LP'""",
|
|
|
+ [INV_NO, CUS_NO,CUS_NO_NAME,CUS_NO_NAME,AMT,INV_DD,UNI_NO_PAY,SAL_ADR,SAL_TEL,SAL_KH_BANK,SAL_ID_CODE,REM,ZL_NO])
|
|
|
+ # BIL_NO 开票单号 ZL_NO
|
|
|
+ # INV_NO 开票号码 INV_NO
|
|
|
+ # CUS_NO 开票客户编码 CUS_NO
|
|
|
+ # TITLE_BUY 客户名 CUS_NO_NAME
|
|
|
+ # TITLE_PAY 客户名 CUS_NO_NAME
|
|
|
+ # AMT 金额 AMT
|
|
|
+ #INV_DD 日期 INV_DD
|
|
|
+ #UNI_NO_PAY UNI_NO_PAY
|
|
|
+ # SAL_ADR SAL_ADR
|
|
|
+ #SAL_TEL SAL_TEL
|
|
|
+ # SAL_KH_BANK SAL_KH_BANK
|
|
|
+ # SAL_ID_CODE SAL_ID_CODE
|
|
|
+ #REM REM
|
|
|
+
|
|
|
+ # 修改立账单MF_MRP
|
|
|
+ cursor.execute("""UPDATE MF_ARP SET CUS_NO=%s,PAY_DD=%s,INV_NO=%s,AMT=%s,AMTN=%s,AMTN_NET=%s,SYS_DATE=%s WHERE ARP_NO=%s AND BIL_ID='LP'""", [CUS_NO, datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),
|
|
|
+ INV_NO,AMT,AMT,AMT,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),'AP' + ZL_NO[2::]])
|
|
|
+ # ARP_NO 立账单号 'AP' + ZL_NO[2::]
|
|
|
+ # CUS_NO 客户代号 CUS_NO
|
|
|
+ # PAY_DD 立账日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
+ #INV_NO 发票号码 INV_NO
|
|
|
+ # AMT 金额 AMT
|
|
|
+ # AMTN AMT
|
|
|
+ # AMTN_NET AMT
|
|
|
+ # SYS_DATE 录入日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
+
|
|
|
+ # 插入进货开票表头
|
|
|
+ cursor.execute("""UPDATE MF_LZ1 SET PAY_DD=%s,LZ_DD=%s,CUS_NO=%s,INV_NO=%s,AMT=%s,AMTN_NET=%s,MODIFY_DD=%s,MODIFY_MAN=USR WHERE LZ_NO=%s AND LZ_ID='LP'""",
|
|
|
+ [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),CUS_NO,INV_NO,AMT,AMT,UP_DD,ZL_NO])
|
|
|
+ # LZ_NO 单号 ZL_NO
|
|
|
+ # PAY_DD 日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
+ # LZ_DD 日期 datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
|
|
|
+ # CUS_NO 客户编码 CUS_NO
|
|
|
+ # INV_NO 发票号码 INV_NO
|
|
|
+ # AMT 金额 AMT
|
|
|
+ # AMTN_NET 金额 AMT
|
|
|
+
|
|
|
+ # 修改进货开票表身
|
|
|
+ cursor.execute("""UPDATE TF_LZ1 SET AMT=%s,AMTN_NET=%s,CUS_NO=%s WHERE LZ_NO=%s AND LZ_ID='LP'""", [AMT, AMT,CUS_NO,ZL_NO])
|
|
|
+ # LZ_NO 单号 ZL_NO
|
|
|
+ # AMT 金额 AMT
|
|
|
+ # AMTN_NET 金额 AMT
|
|
|
+ # CUS_NO 客户 CUS_NO
|
|
|
+ # # 修改开完发票回写进货单表身已开金额
|
|
|
+ # cursor.execute("""UPDATE TF_PSS SET AMT_FP=%s,AMTN_NET_FP=%s WHERE PS_NO=%s""",[AMT, AMT, 'PC' + ZL_NO[2::]])
|
|
|
+ # 不开票
|
|
|
+ if int(ZHANG_ID)==1:
|
|
|
+ cursor.execute(
|
|
|
+ """UPDATE MF_PSS SET PS_DD=%s,CUS_NO=%s,ZHANG_ID=%s,AMT=%s,MODIFY_DD=%s,MODIFY_MAN=USR WHERE PS_NO=%s AND PS_ID='PC'""",
|
|
|
+ [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), CUS_NO, ZHANG_ID, AMT, UP_DD, 'PC' + ZL_NO[2::]])
|
|
|
+ # 修改进货单表身
|
|
|
+ # PS_DD日期
|
|
|
+ # UP 单价
|
|
|
+ # AMT 金额
|
|
|
+ # AMTN_NET 金额
|
|
|
+ # CSTN_SAL 立账金额
|
|
|
+ cursor.execute("""UPDATE TF_PSS SET PS_DD=%s,UP=%s,AMTN_NET=%s,CSTN_SAL=%s,AMT=%s WHERE PS_NO=%s AND PS_ID='PC'""",
|
|
|
+ [datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), AMT, AMT, AMT, AMT, 'PC' + ZL_NO[2::]])
|
|
|
+ # 修改立账金额
|
|
|
+ cursor.execute(
|
|
|
+ """UPDATE MF_ARP SET CUS_NO=%s,PAY_DD=%s,AMT=%s,AMTN=%s,AMTN_NET=%s,SYS_DATE=%s WHERE ARP_NO=%s AND BIL_ID='PC'""",
|
|
|
+ [CUS_NO, datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), AMT, AMT, AMT, datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'), 'AP' + ZL_NO[2::]])
|
|
|
context = {
|
|
|
'a': 'PUT提交'
|
|
|
}
|
|
@@ -262,20 +306,54 @@ class InvoiceView(View):
|
|
|
# 获取传过来的参数
|
|
|
req_data = json.loads(request.body.decode())
|
|
|
ZL_NO = req_data.get("ZL_NO") # 单据号码
|
|
|
+ ZHANG_ID = req_data.get("ZHANG_ID") #立账方式
|
|
|
+
|
|
|
+ # 判断立账方式是否有效
|
|
|
+ if int(ZHANG_ID) != 1 and int(ZHANG_ID) != 2:
|
|
|
+ return http.HttpResponseForbidden('立账方式只能是1(开票),2(不开票)')
|
|
|
+ # 判断进货单号是存在
|
|
|
+ if int(ZHANG_ID) == 1:
|
|
|
+ row_ZL_NO = examine_ood('MF_PSS', 'PS_NO', 'PC' + ZL_NO[2::],'PS_ID','PC')
|
|
|
+ if row_ZL_NO <= 0:
|
|
|
+ return http.HttpResponseForbidden('进货单号不存在')
|
|
|
+ # 判断开票单号是否存在
|
|
|
+ if int(ZHANG_ID) > 2:
|
|
|
+ row_ZL_NO = examine_ood('MF_LZ1', 'LZ_NO', ZL_NO,'LZ_ID','LP')
|
|
|
+ if row_ZL_NO <= 0:
|
|
|
+ return http.HttpResponseForbidden('开票单号不存在')
|
|
|
+
|
|
|
with connection.cursor() as cursor:
|
|
|
|
|
|
- # 删除进货来票作业表头
|
|
|
- cursor.execute("""DELETE FROM TF_LZ1 WHERE LZ_NO=%s""", [ZL_NO])
|
|
|
- # 删除进货开票作业表身
|
|
|
- cursor.execute("""DELETE FROM MF_LZ1 WHERE LZ_NO=%s""", [ZL_NO])
|
|
|
- #删除立账金额单据
|
|
|
- cursor.execute("""DELETE FROM MF_ARP WHERE BIL_NO=%s""", [ZL_NO])
|
|
|
- #删除发票单据
|
|
|
- cursor.execute("""DELETE FROM INV_NO WHERE BIL_NO=%s""", [ZL_NO])
|
|
|
- # 删除进货单表身单据
|
|
|
- cursor.execute("""DELETE FROM MF_PSS WHERE PS_NO=%s""", ['PC' + ZL_NO[2::]])
|
|
|
- # 删除进货单表头单据
|
|
|
- cursor.execute("""DELETE FROM TF_PSS WHERE PS_NO=%s""", ['PC' + ZL_NO[2::]])
|
|
|
+ if int(ZHANG_ID)==2:
|
|
|
+ # 判断是否产生后续单据
|
|
|
+ sql = "SELECT COUNT(*) FROM %s WHERE %s='%s'" % ('TC_MON', 'ARP_NO', 'AP' + ZL_NO[2::])
|
|
|
+ row_ZL_NO = cursor.execute(sql).fetchall()[0][0]
|
|
|
+ if row_ZL_NO > 0:
|
|
|
+ return http.HttpResponseForbidden('开票单或进货单已产生后续收付款单')
|
|
|
+ # 删除进货来票作业表头
|
|
|
+ cursor.execute("""DELETE FROM TF_LZ1 WHERE LZ_NO=%s AND LZ_ID='LP'""", [ZL_NO])
|
|
|
+ # 删除进货开票作业表身
|
|
|
+ cursor.execute("""DELETE FROM MF_LZ1 WHERE LZ_NO=%s AND LZ_ID='LP'""", [ZL_NO])
|
|
|
+ #删除立账金额单据
|
|
|
+ cursor.execute("""DELETE FROM MF_ARP WHERE BIL_NO=%s AND BIL_ID='LP'""", [ZL_NO])
|
|
|
+ #删除发票单据
|
|
|
+ cursor.execute("""DELETE FROM INV_NO WHERE BIL_NO=%s AND BIL_ID='LP'""", [ZL_NO])
|
|
|
+ # 删除进货单表身单据
|
|
|
+ cursor.execute("""DELETE FROM MF_PSS WHERE PS_NO=%s AND PS_ID='PC'""", ['PC' + ZL_NO[2::]])
|
|
|
+ # 删除进货单表头单据
|
|
|
+ cursor.execute("""DELETE FROM TF_PSS WHERE PS_NO=%s AND PS_ID='PC'""", ['PC' + ZL_NO[2::]])
|
|
|
+ if int(ZHANG_ID)==1:
|
|
|
+
|
|
|
+ # 判断是否产生后续单据
|
|
|
+ sql = "SELECT COUNT(*) FROM %s WHERE %s='%s'" % ('TC_MON', 'ARP_NO', 'AP' + ZL_NO[2::])
|
|
|
+ row_ZL_NO = cursor.execute(sql).fetchall()[0][0]
|
|
|
+ if row_ZL_NO > 0:
|
|
|
+ return http.HttpResponseForbidden('开票单或进货单已产生后续收付款单')
|
|
|
+ cursor.execute("""DELETE FROM MF_PSS WHERE PS_NO=%s AND PS_ID='PC'""", ['PC' + ZL_NO[2::]])
|
|
|
+ # 删除进货单表头单据
|
|
|
+ cursor.execute("""DELETE FROM TF_PSS WHERE PS_NO=%s AND PS_ID='PC'""", ['PC' + ZL_NO[2::]])
|
|
|
+ # 删除进货单表身单据
|
|
|
+ cursor.execute("""DELETE FROM MF_ARP WHERE BIL_NO=%s AND BIL_ID='PC'""", ['PC' + ZL_NO[2::]])
|
|
|
context = {
|
|
|
'a': 'DELETE提交'
|
|
|
}
|