소스 검색

开票申请时,系统可根据单个客户的不同设置,在订单审核完成后,就可以针对订单进行开票申请
1.经销商档案新增配置项:是否订单审核可开票
2.在开票申请单据中,选择可开票范围时,系统根据经销商的开票节点进行可开票订单行的筛选

沈静伟 4 년 전
부모
커밋
203d040832

+ 10 - 7
src/apps/tinvoiceapply/tinvoiceapplyMlt.java

@@ -12,14 +12,17 @@ public class tinvoiceapplyMlt extends MultiselectDataBeanCust {
         try {
             tinvoiceapply pao = (tinvoiceapply) this.app.getAppBean().getPao();
             String fagentnum = pao.getString("fagentnum");
-            String finvoicetaxnumber = pao.getString("finvoicetaxnumber");
+            //String finvoicetaxnumber = pao.getString("finvoicetaxnumber");
+            boolean fcheckordermakeinv = pao.getPaoSet("tagents").getPao(0).getBoolean("fcheckordermakeinv");
             PaoSetRemote detailset = pao.getPaoSet("tinvoiceapplyorder");
-            paoSet.setWhere("exists(select *from SAORDER_RECEIVEDVIEW where siteid=saorderdetail.siteid and saorderid=saorderdetail.fparentid and saorderdetailid=saorderdetail.saorderdetailid and isnull(freceivedamount,0)>isnull(saorderdetail.finvoiceamount,0) ) and " +
-                    "exists(select * from saorder where fstatus in('审核','关闭') and siteid=saorderdetail.siteid and saorderid=saorderdetail.fparentid and fpayagentnum='" + fagentnum + "' " +
-                    //"and finvoicetaxnumber='" + finvoicetaxnumber + "'" +
-                    ") " +
-                    "and " +
-                    getworlds(detailset, "saorderdetailid", "saorderdetailid"));
+            if (fcheckordermakeinv) {
+                paoSet.setWhere("exists(select * from saorder where fstatus in('审核','关闭') and siteid=saorderdetail.siteid and saorderid=saorderdetail.fparentid and fpayagentnum='" + fagentnum + "' " + ") " +
+                        "and " + getworlds(detailset, "saorderdetailid", "saorderdetailid"));
+            } else {
+                paoSet.setWhere("exists(select *from SAORDER_RECEIVEDVIEW where siteid=saorderdetail.siteid and saorderid=saorderdetail.fparentid and saorderdetailid=saorderdetail.saorderdetailid and isnull(freceivedamount,0)>isnull(saorderdetail.finvoiceamount,0) ) and " +
+                        "exists(select * from saorder where fstatus in('审核','关闭') and siteid=saorderdetail.siteid and saorderid=saorderdetail.fparentid and fpayagentnum='" + fagentnum + "' " + ") " +
+                        "and " + getworlds(detailset, "saorderdetailid", "saorderdetailid"));
+            }
         } catch (Exception e) {
             paoSet.setWhere("1=2");
             e.printStackTrace();

+ 29 - 14
src/apps/tinvoiceapplyorder/tinvoiceapplyorder.java

@@ -21,14 +21,22 @@ public class tinvoiceapplyorder extends PaoCust {
             if ("机瞄".equals(getOwner().getString("fstatus"))) {
                 setFieldFlag(new String[]{"finvoiceamount", "finvoiceqty"}, READONLY, true);
             }
+            boolean fcheckordermakeinv = getOwner().getPaoSet("tagents").getPao(0).getBoolean("fcheckordermakeinv");
             PaoRemote saorderdetail = getPaoSet("saorderdetail").getPao(0);
-            PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
-            double freceivedamount = 0;
-            if (!saorder_receivedviewSet.isEmpty()) {
-                freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//隆等眒彶億踢塗
+            if (fcheckordermakeinv) {
+                double frateamount = saorderdetail.getDouble("frateamount");//隆等踢塗
+                double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//隆等眒羲⑺踢塗
+                setValue("funinvoiceamount", Math.sub(frateamount, finvoiceamount_order), 11L);
+            } else {
+                PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
+                double freceivedamount = 0;
+                if (!saorder_receivedviewSet.isEmpty()) {
+                    freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//隆等眒彶億踢塗
+                }
+                double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//隆等眒羲⑺踢塗
+                setValue("funinvoiceamount", Math.sub(freceivedamount, finvoiceamount_order), 11L);
             }
-            double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//隆等眒羲⑺踢塗
-            setValue("funinvoiceamount", Math.sub(freceivedamount, finvoiceamount_order), 11L);
+
         }
     }
 
@@ -47,19 +55,26 @@ public class tinvoiceapplyorder extends PaoCust {
     public void fieldAction(Object paoField, String fieldname) throws P2Exception {
         super.fieldAction(paoField, fieldname);
         if ("SAORDERDETAILID".equals(fieldname)) {
+            boolean fcheckordermakeinv = getOwner().getPaoSet("tagents").getPao(0).getBoolean("fcheckordermakeinv");
             PaoRemote saorderdetail = getPaoSet("saorderdetail").getPao(0);
-            PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
-            double freceivedamount = 0;
-            if (!saorder_receivedviewSet.isEmpty()) {
-                freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//隆等眒彶億踢塗
-            }
             double finvoiceamount_order = saorderdetail.getDouble("finvoiceamount");//隆等眒羲⑺踢塗
             double frateprice = saorderdetail.getDouble("frateprice");//等歎
-            setValue("funinvoiceamount", Math.sub(freceivedamount, finvoiceamount_order), 11L);
-            setValue("finvoiceamount", Math.sub(freceivedamount, finvoiceamount_order), 11L);
+            if (fcheckordermakeinv) {
+                double frateamount = saorderdetail.getDouble("frateamount");//隆等踢塗
+                setValue("funinvoiceamount", Math.sub(frateamount, finvoiceamount_order), 11L);
+                setValue("finvoiceamount", Math.sub(frateamount, finvoiceamount_order), 11L);
+
+            } else {
+                PaoSetRemote saorder_receivedviewSet = saorderdetail.getPaoSet("saorder_receivedview");
+                double freceivedamount = 0;
+                if (!saorder_receivedviewSet.isEmpty()) {
+                    freceivedamount = saorder_receivedviewSet.getPao(0).getDouble("freceivedamount");//隆等眒彶億踢塗
+                }
+                setValue("funinvoiceamount", Math.sub(freceivedamount, finvoiceamount_order), 11L);
+                setValue("finvoiceamount", Math.sub(freceivedamount, finvoiceamount_order), 11L);
+            }
             setValue("fprice", frateprice, 11L);
             setValue("finvoiceqty", getDouble("finvoiceamount") / frateprice, 11L);
-
         } else if ("FINVOICEAMOUNT".equals(fieldname)) {
             setValue("finvoiceqty", getDouble("finvoiceamount") / getDouble("fprice"), 11L);
         } else if ("FINVOICEQTY".equals(fieldname)) {

+ 2 - 1
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/SQL/开票经销商选择查询_业务员.sql

@@ -1,5 +1,6 @@
-
 select fagentnum,fagentname from tagents
 where siteid=$siteid$ and
+(fcheckordermakeinv=1 or
 exists(select distinct t1.fpayagentnum from saorder t1 inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid inner join SAORDER_RECEIVEDVIEW t3 on t2.fparentid=t3.saorderid and t2.saorderdetailid=t3.saorderdetailid where isnull(t3.freceivedamount,0)>isnull(t2.finvoiceamount,0) and t1.fpayagentnum=tagents.fagentnum)
+)
 and exists (select fagentnum from tagents_field where hrid in $hrid$ and siteid=tagents.siteid and fagentnum=tagents.fagentnum )

+ 10 - 0
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/SQL/开票订单行选择查询_审核订单.sql

@@ -0,0 +1,10 @@
+select *,t2.freceivedamount,tp.fprojectname,sdate.closedate1 from saorderdetail t1
+left join saorder_receivedview t2 on t1.siteid=t2.siteid and t1.saorderdetailid=t2.saorderdetailid
+inner join tagents t3 on t1.siteid=t3.siteid and t3.fagentnum=$fagentnum$ and fcheckordermakeinv=1
+inner join saorder sa on t1.fparentid = sa.saorderid and sa.fpayagentnum=$fagentnum$ and sa.fstatus in('ÉóºË','¹Ø±Õ')
+left join tproject tp on sa.fprojectnum = tp.fprojectnum and sa.siteid=tp.siteid
+left join sainvoice_closedate sdate on sdate.fsourceid = t1.saorderdetailid
+where t1.siteid=$siteid$ and isnull(t1.frateamount,0)>isnull(t1.finvoiceamount,0)
+and not exists(
+    select *from tinvoiceapplyorder where siteid=$siteid$ and tinvoiceapplyid=$tinvoiceapplyid$ and saorderdetailid=t1.saorderdetailid
+) and $where$

+ 4 - 2
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/Tinvoiceapply.java

@@ -250,14 +250,16 @@ public class Tinvoiceapply extends Controller {
         if (!"".equals(condition)) {
             where = where + " and (tp.fprojectname like'%" + condition + "%' or t1.fsonum like'%" + condition + "%')";
         }
+        DBConnect connect = new DBConnect();
+        Rows tagentsRows = connect.runSqlQuery("select *from tagents where siteid='" + siteid + "' and fagentnum='" + fagentnum + "'");
+        boolean fcheckordermakeinv = tagentsRows.get(0).getBoolean("fcheckordermakeinv");
 
-        SQLFactory factory = new SQLFactory(this, "역튿땐데契朞嶝꿴璂");
+        SQLFactory factory = new SQLFactory(this, fcheckordermakeinv ? "역튿땐데契朞嶝꿴璂_�뵙땐데" : "역튿땐데契朞嶝꿴璂");
         factory.addParameter("siteid", siteid);
         factory.addParameter("fagentnum", fagentnum);
         factory.addParameter_SQL("where", where);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
 
-        DBConnect connect = new DBConnect();
         Rows rows = connect.runSqlQuery(factory.getSQL());
         return getReturnObject_suc(rows, false).toString();
 

+ 5 - 2
src/rest/openapi/restcontroller/wechatapp/tinvoiceapply/Tinvoiceapply_saler.java

@@ -283,13 +283,16 @@ public class Tinvoiceapply_saler extends Controller {
         if (!"".equals(condition)) {
             where = where + " and (tp.fprojectname like'%" + condition + "%' or t1.fsonum like'%" + condition + "%')";
         }
-        SQLFactory factory = new SQLFactory(this, "역튿땐데契朞嶝꿴璂");
+        DBConnect connect = new DBConnect();
+        Rows tagentsRows = connect.runSqlQuery("select *from tagents where siteid='" + siteid + "' and fagentnum='" + fagentnum + "'");
+        boolean fcheckordermakeinv = tagentsRows.get(0).getBoolean("fcheckordermakeinv");
+
+        SQLFactory factory = new SQLFactory(this, fcheckordermakeinv ? "역튿땐데契朞嶝꿴璂_�뵙땐데" : "역튿땐데契朞嶝꿴璂");
         factory.addParameter("siteid", siteid);
         factory.addParameter("fagentnum", fagentnum);
         factory.addParameter_SQL("where", where);
         factory.addParameter("tinvoiceapplyid", tinvoiceapplyid);
 
-        DBConnect connect = new DBConnect();
         Rows rows = connect.runSqlQuery(factory.getSQL());
         return getReturnObject_suc(rows, false).toString();
     }