Browse Source

今天代码结束

任翠亮 5 years ago
parent
commit
ede2ff0e8a

+ 107 - 4
awj/awj/apps/PaymentOperation/views.py

@@ -7,21 +7,124 @@ from django.shortcuts import render
 from django.views import View
 from django.db import connection
 
+from utils.examine_ood import examine_ood
+from utils.usr_data import usr_data
+import datetime
+
 class PaymentOperationView(View):
     def get(self,request):
-        a='A000002'
+        a='TF_MON'
+        b='RP_NO'
+        c='PT20191015' #为0.000
+        sql="SELECT COUNT(*) FROM %s WHERE %s='%s' "%(a,b,c)
+        print(sql)
         with connection.cursor() as cursor:
             # cursor.execute("INSERT INTO CUST(CUS_NO,[NAME])VALUES ('QQ12345',%s)",[a])
             # cursor.execute("UPDATE PRDT SET NAME='呜呜呜呜' where prd_no = %s", [a])
-            cursor.execute("select * from prdt where prd_no = %s", [a])
-            row = cursor.fetchall()
-            print(row)
+            # cursor.execute("select * from prdt where prd_no = %s", [a])
+            # row_ZL_NO = cursor.execute("SELECT * FROM MF_ARP WHERE BIL_NO=%s", [a]).fetchall()[0][0]
+            row_ZL_NO = cursor.execute(sql).fetchall()[0][0]
+            print(row_ZL_NO)
         context={
             'a':'get付款作业'
         }
         return http.JsonResponse(context)
 
     def post(self, request):
+
+        # 获取参数
+        RP_NO = request.POST.get("RP_NO")  #付款单号         字符类型
+        RP_DD = request.POST.get("RP_DD")  #付款日期            字符类型
+        CUS_NO = request.POST.get("CUS_NO")  #付款客户编码        字符类型
+        AMTN_BC = request.POST.get("AMTN_BC")  #付款金额            数字类型
+        CACC_NO = request.POST.get("CACC_NO")  #付款银行编码          字符类型
+        USR = request.POST.get("USR")  #制单人编码                   字符类型
+        USR_NAME = request.POST.get("USR_NAME")  #制单人姓名         字符类型
+        MF_LZ1 = request.POST.get("MF_LZ1")  #进货开票单号         字符类型
+
+
+        # 判断单号是否存在
+        row_ZL_NO = examine_ood('TF_MON', 'RP_NO', RP_NO)
+        if row_ZL_NO > 0:
+            return http.HttpResponseForbidden('单号重复')
+
+        # 判断用户是否存在,不存在则创建
+        row_usr = usr_data(USR, USR_NAME,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'))
+        with connection.cursor() as cursor:
+
+            # cursor.execute("""UPDATE TF_PSS SET AMT_FP=%s,AMTN_NET_FP=%s WHERE PS_NO=%s""",[AMT, AMT, 'PC' + ZL_NO[2::]])
+            #插入付款单表头
+            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('F',%s,1,2,'T',%s,%s,'F',%s,%s,%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,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
+            #AMTN_CLS    冲款金额      AMTN_CLS
+            #BC_NO      账户收支单号
+            #CACC_NO    'BT'+RP_NO[2::]
+            #CACC_NO        付款银行编码
+            #USR   制单人      USR
+            #CHK_MAN   审核人      USR
+            #CLS_DATE    制单时间       datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
+            #CLS_DATE       审核时间        datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
+
+            # 插入付款单表身-------------改CUR_ID  RMB
+            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,1,%s,%s,2,%s,%s,1)""",
+            [RP_NO, 'AP'+MF_LZ1[2::], AMTN_BC,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'),CUS_NO])
+            # RP_NO   付款单号  RP_NO
+            #ARP_NO   立账单号      MF_LZ1
+            #AMTN_CLS  冲款金额  AMTN_BC
+            #RP_DD  冲款时间    datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
+            #CUS_NO   冲款客户      CUS_NO
+
+            # 插入回写冲款金额表
+            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,%s,%s,0)""",[RP_NO,datetime.datetime.strptime(RP_DD, '%Y-%m-%d'), AMTN_BC,AMTN_BC,AMTN_BC])
+            #RP_NO  付款单号  RP_NO
+            #AMTN   冲款金额
+            #AMTN_ARP  总金额
+            #AMTN_REST
+
+            # 插入账户收支单表头
+            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,'PT'+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   账户收支单日期  RP_NO[2::], datetime.datetime.strptime(RP_DD, '%Y-%m-%d')
+            # BACC_NO  银行账户代号
+            #ACC_NO  会计科目      待定,需要会计确定自动取银行账号里面的会计科目
+            #BIL_NO  来源单号   'PT'+RP_NO
+            #AMTN 金额   付款是负数,收款是正数      AMTN_BC
+            #USR  制单人       USR
+            #  CHK_MAN  审核人     USR
+            #CLS_DATE  审核日期
+            # SYS_DATE  录入日期
+            #BIL_NO_N  来源单号
+
+            # 插入账户收支单表身
+            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,'0000',%s,'-',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
+
+            #回写立账单的数据
+            cursor.execute("""UPDATE MF_ARP SET AMTN_RCV=ISNULL(AMTN_RCV,0)+%s,AMT=ISNULL(AMT,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", [MF_LZ1]).fetchall()[0][0]
+            if row_AMT==0:
+                cursor.execute("""UPDATE MF_ARP SET CLOSE_ID='T' WHERE BIL_NO=%s""",[MF_LZ1])
+                cursor.execute("""UPDATE MF_PSS SET LZ_CLS_ID='T',CLSLZ='T' WHERE PS_NO=%s""",['PC'+MF_LZ1[2::]])
         context = {
             'a': 'post付款作业'
         }

+ 17 - 17
awj/awj/apps/stockinvoice/views.py

@@ -9,7 +9,7 @@ from django.db import connection
 import datetime
 
 from utils.cust_data import customer_data
-from utils.judge_bills import judge_bills
+from utils.examine_ood import examine_ood
 from utils.usr_data import usr_data
 
 
@@ -64,23 +64,23 @@ class InvoiceView(View):
         print(USR_NAME)     #制单人姓名   1
 
         # 判断单号是否存在
-        row_ZL_NO = judge_bills(ZL_NO)
+        row_ZL_NO = examine_ood('MF_LZ1','LZ_NO',ZL_NO)
         if row_ZL_NO > 0:
             return http.HttpResponseForbidden('单号重复')
 
         #判断客户资料是否存在,不存在则创建
-        row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2')
+        row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2',datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'))
 
         # 判断用户是否存在,不存在则创建
-        row_usr = usr_data(USR,USR_NAME)
+        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:
-            # 插入进货单表头
-                cursor.execute("""INSERT INTO MF_PSS(PS_ID,PS_NO,PS_DD,CUS_NO,ZHANG_ID,USR,CHK_MAN,CLS_DATE,SYS_DATE,AMT,CUR_ID,EXC_RTO,LZ_CLS_ID,CLSLZ,TAX_ID)
+            # 插入进货单表头-----------------------改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,
-                'RMB',1,'F','F',1)""", ['PC'+ZL_NO[2::], datetime.datetime.strptime(LZ_DD,'%Y-%m-%d'),CUS_NO,USR,USR,datetime.datetime.strptime(LZ_DD,'%Y-%m-%d'),
+                1,'F','F',1)""", ['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])
             #插入进货单表身
                 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)
@@ -91,15 +91,15 @@ class InvoiceView(View):
                 VALUES(%s,%s,'LP',21,%s,%s,%s,%s,1,1,1,%s,%s,%s,%s,%s,%s,%s)""",[ZL_NO, INV_NO, CUS_NO, CUS_NO_NAME, CUS_NO_NAME, AMT,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),
                  UNI_NO_PAY,SAL_ADR,SAL_TEL,SAL_KH_BANK,SAL_ID_CODE,REM])
 
-            #插入立账单MF_MRP
-                cursor.execute("""INSERT INTO MF_ARP(ARP_ID,OPN_ID,ARP_NO,BIL_NO,CUS_NO,PAY_DD,INV_NO,AMT,AMTN,AMTN_NET,CUR_ID,EXC_RTO,CLOSE_ID,BIL_ID,SYS_DATE)VALUES
-                (2,2,%s,%s,%s,%s,%s,%s,%s,%s,'RMB',1,'F','LP',%s)""", [ 'AP'+ZL_NO[2::],ZL_NO,CUS_NO,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),INV_NO
-                ,AMT,AMT,AMT,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')])
+            #插入立账单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','LP',%s,%s)""", [ 'AP'+ZL_NO[2::],ZL_NO,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')])
 
-            #插入进货开票表头
-                cursor.execute("""INSERT INTO MF_LZ1(LZ_ID,LZ_NO,PAY_DD,LZ_DD,CUS_NO,INV_NO,CUR_ID,EXC_RTO,USR,CHK_MAN,AMT,AMTN_NET,ARP_NO,CLS_DATE,TAX_ID,ZHANG_ID,
+            #插入进货开票表头--------------改CUR_ID    RMB
+                cursor.execute("""INSERT INTO MF_LZ1(LZ_ID,LZ_NO,PAY_DD,LZ_DD,CUS_NO,INV_NO,EXC_RTO,USR,CHK_MAN,AMT,AMTN_NET,ARP_NO,CLS_DATE,TAX_ID,ZHANG_ID,
             SYS_DATE,VOH_CHK,TURN_ID,INV_BIL_ID,INV_BIL_NO,FLG_VOH)VALUES
-            ('LP',%s,%s,%s,%s,%s,'RMB',1,%s,%s,
+            ('LP',%s,%s,%s,%s,%s,1,%s,%s,
             %s,%s,%s,%s,'1',3,%s,1,1,'LP',%s,'F')""", [ZL_NO, datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
             ,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),CUS_NO,INV_NO,USR,USR,AMT,AMT,'AP'+ZL_NO[2::],datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),datetime.datetime.strptime(LZ_DD, '%Y-%m-%d')
             ,ZL_NO])
@@ -158,15 +158,15 @@ class InvoiceView(View):
         #     "REM": "我的备注",
         # }
         # 判断单号是否存在
-        row_ZL_NO = judge_bills(ZL_NO)
+        row_ZL_NO = examine_ood('MF_LZ1', 'LZ_NO', ZL_NO)
         if row_ZL_NO == 0:
             return http.HttpResponseForbidden('单号不存在')
 
         #判断厂商是否存在,不存在则自动创建
-        row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2')
+        row_cus_no = customer_data(CUS_NO, CUS_NO_NAME, '2',datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'))
 
         # 判断用户是否存在,不存在则创建
-        row_usr = usr_data(USR, USR_NAME)
+        row_usr = usr_data(USR, USR_NAME,datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'))
 
         with connection.cursor() as cursor:
             # 修改进货单表头

+ 15 - 0
awj/awj/apps/stockinvoice/xixi.py

@@ -0,0 +1,15 @@
+from django.db import connection
+
+# 用于判断进货开票单是否存在
+a = 'LP9A150003'
+def invoice_order(oo_no):
+    """
+    :param oo_no: 单号
+    :return:
+    """
+    with connection.cursor() as cursor:
+        # 判断单号是否重复
+        row_ZL_NO = cursor.execute("SELECT AMT FROM MF_ARP WHERE BIL_NO=%s", [oo_no]).fetchall()[0][0]
+        return row_ZL_NO
+b = invoice_order(a)
+print(b)

+ 2 - 2
awj/awj/utils/cust_data.py

@@ -1,6 +1,6 @@
 from django.db import connection
 
-def customer_data(CUS_NO,CUS_NO_NAME,OBJ_ID):
+def customer_data(CUS_NO,CUS_NO_NAME,OBJ_ID,DATE):
     """
     :param CUS_NO: 客户/厂商编码
     :param CUS_NO_NAME: 客户/厂商名称
@@ -10,5 +10,5 @@ def customer_data(CUS_NO,CUS_NO_NAME,OBJ_ID):
     with connection.cursor() as cursor:
         row_cus_no = cursor.execute("SELECT COUNT(*) FROM CUST WHERE CUS_NO=%s", [CUS_NO]).fetchall()[0][0]
         if row_cus_no == 0:
-            cursor.execute("INSERT INTO CUST(CUS_NO,[NAME],OBJ_ID)VALUES (%s,%s,%s)", [CUS_NO, CUS_NO_NAME,OBJ_ID])
+            cursor.execute("INSERT INTO CUST(CUS_NO,[NAME],OBJ_ID,USR1,CHK_MAN,CLS_DATE,SYS_DATE,DEP)VALUES (%s,%s,%s,%s,%s,%s,%s,'0000')", [CUS_NO, CUS_NO_NAME,OBJ_ID,'ADMIN','ADMIN',DATE,DATE])
     return "ok"

+ 17 - 0
awj/awj/utils/examine_ood.py

@@ -0,0 +1,17 @@
+from django.db import connection
+
+# 用于判断进货开票单是否存在
+
+def examine_ood(TB,TYPE,OOD):
+    """
+
+    :param TB: 表名
+    :param TYPE: 字段名
+    :param OOD: 单号
+    :return:
+    """
+    sql = "SELECT COUNT(*) FROM %s WHERE %s='%s' " % (TB, TYPE, OOD)
+    with connection.cursor() as cursor:
+        # 判断单号是否重复
+        row_ZL_NO = cursor.execute(sql).fetchall()[0][0]
+        return row_ZL_NO

+ 0 - 11
awj/awj/utils/judge_bills.py

@@ -1,11 +0,0 @@
-from django.db import connection
-
-def judge_bills(oo_no):
-    """
-    :param oo_no: 单号
-    :return:
-    """
-    with connection.cursor() as cursor:
-        # 判断单号是否重复
-        row_ZL_NO = cursor.execute("SELECT COUNT(*) FROM MF_LZ1 WHERE LZ_NO=%s", [oo_no]).fetchall()[0][0]
-        return row_ZL_NO

+ 2 - 2
awj/awj/utils/usr_data.py

@@ -1,6 +1,6 @@
 from django.db import connection
 
-def usr_data(USR,USR_NAME):
+def usr_data(USR,USR_NAME,DATE):
     """
 
     :param USR: 用户代号
@@ -10,5 +10,5 @@ def usr_data(USR,USR_NAME):
     with connection.cursor() as cursor:
         row_usr = cursor.execute("SELECT COUNT(*) FROM SALM WHERE SAL_NO=%s", [USR]).fetchall()[0][0]
         if row_usr == 0:
-            cursor.execute("INSERT INTO SALM(SAL_NO,[NAME])VALUES (%s,%s)", [USR, USR_NAME])
+            cursor.execute("INSERT INTO SALM(SAL_NO,[NAME],USR,CHK_MAN,CLS_DATE,SYS_DATE)VALUES (%s,%s,'ADMIN','ADMIN',%s,%s)", [USR, USR_NAME,DATE,DATE])
     return "ok"