Browse Source

进货开票子应用

任翠亮 5 years ago
parent
commit
d4d6c63b0a

+ 0 - 0
awj/awj/apps/stockinvoice/__init__.py


+ 3 - 0
awj/awj/apps/stockinvoice/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 5 - 0
awj/awj/apps/stockinvoice/apps.py

@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class StockinvoiceConfig(AppConfig):
+    name = 'stockinvoice'

+ 0 - 0
awj/awj/apps/stockinvoice/migrations/__init__.py


+ 3 - 0
awj/awj/apps/stockinvoice/models.py

@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.

+ 3 - 0
awj/awj/apps/stockinvoice/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 84 - 0
awj/awj/apps/stockinvoice/views.py

@@ -0,0 +1,84 @@
+from django import http
+from django.shortcuts import render
+
+# Create your views here.
+from django.views import View
+from django.db import connection
+import datetime
+
+class InvoiceView(View):
+    def get(self,request):
+        a='A000002'
+        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)
+        context={
+            '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
+        TAX_ID = request.POST.get("TAX_ID")   #扣税类别   1
+        AMT = request.POST.get("AMT")   #开票金额        1
+        CUS_NO = request.POST.get("CUS_NO")   #开票客户编码    1
+        CUS_NO_NAME = request.POST.get("CUS_NO_NAME")   #开票客户名称     1
+        UNI_NO_PAY = request.POST.get("UNI_NO_PAY")   #纳税人识别码   1
+        SAL_ADR = request.POST.get("SAL_ADR")   #开票客户地址   1
+        SAL_TEL = request.POST.get("SAL_TEL")   #开票客户电话   1
+        USR = request.POST.get("USR")   #制单人编码   1
+        USR_NAME = request.POST.get("USR_NAME")   #制单人姓名   1
+        print(ZL_NO)   #单据号码    1
+        print(LZ_DD)   #单据日期    1
+        print(INV_NO)   #发票号码    1
+        print(INV_DD)    #发票日期     1
+        print(ZHANG_ID)    #立账方式   1
+        print(TAX_ID)     #扣税类别   1
+        print(AMT)       #开票金额        1
+        print(CUS_NO)   #开票客户编码    1
+        print(CUS_NO_NAME)      #开票客户名称     1
+        print(UNI_NO_PAY)      #纳税人识别码   1
+        print(SAL_ADR)     #开票客户地址   1
+        print(SAL_TEL)       #开票客户电话   1
+        print(USR)      #制单人编码   1
+        print(USR)     #制单人姓名   1
+        a = 'QQ12345'
+        with connection.cursor() as cursor:
+
+            # 判断单号是否重复
+            row_ZL_NO = cursor.execute("SELECT COUNT(*) FROM MF_LZ1 WHERE LZ_NO=%s", [ZL_NO]).fetchall()[0][0]
+            if row_ZL_NO > 0:
+                return http.HttpResponseForbidden('单号重复')
+            #获取查看用户是否存在,不存在则添加
+            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])VALUES (%s,%s)", [CUS_NO,CUS_NO_NAME])
+
+            #获取查看用户是否存在,不存在则插入
+            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])
+
+            #判断是否开票开票
+            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)
+                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'),
+                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)
+            VALUES('PC',%s,%s,'0000','AQ001',1,1,%s,%s,5,1,1,%s)""", ['PC'+ZL_NO[2::], datetime.datetime.strptime(LZ_DD, '%Y-%m-%d'),AMT,AMT,AMT])
+        context = {
+            'a': 'POST提交'
+        }
+        return http.JsonResponse(context)
+
+