ソースを参照

资金模块-付款单/收款单前端后端逻辑调整

huangx 7 年 前
コミット
d706228bb5

+ 7 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -45,7 +45,14 @@ public enum BizExceptionCode implements BaseExceptionCode {
     SALEOUT_POSTSTATUS_ERROR(72004,"当前单据状态无法进行此操作。"),
     SALEOUT_POST_ERROR(72005,""),
     SALEOUT_UNAUDIT_ERROR(72006,"销售订单已转出货单,无法反审核"),
+
     //资金
+    PAYBALANCE_OUTNOWBALANCE(74001,"本次核销金额不能大于未核销金额"),
+    PAYBALANCE_UNIQUESOURCECODE(74002, "保存失败!不能选择重复的源单"),
+
+    RECALANCE_OUTNOWBALANCE(74003,"本次核销金额不能大于未核销金额"),
+
+
 
     //库存
     EMPTY_DATA(76100,"数据为空,请填写后再保存"),

+ 81 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java

@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
@@ -58,6 +59,9 @@ public class PaybalanceServiceImpl implements PaybalanceService {
 
         Long rbId = paybalance.getId();
 
+        //校验数据
+        checkPaybalance(pay);
+
         if (paybalance.getId() > 0){
             paybalanceMapper.updateByPrimaryKeySelective(paybalance);
         }else {
@@ -93,6 +97,63 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         return new DocBaseDTO(rbId, pb_code, BillCodeSeq.PAYBALANCE.getCaller());
     }
 
+    /**
+     * 校验数据
+     * @param pay
+     * @author hx
+     */
+    private void checkPaybalance(Pay pay){
+        Paybalance paybalance = pay.getMain();
+        List<Paybalancedet> paybalancedet = pay.getItems1();
+        List<Paybalancedetail> paybalancedetail = pay.getItems2();
+        //本次核销合计
+        Double nowbalanceTotal = new Double(0);
+        for(Paybalancedetail detail : paybalancedetail){
+            //本次核销金额
+            Double nowbalance = detail.getPbd_nowbalance();
+            nowbalanceTotal = nowbalanceTotal + nowbalance;
+            //来源单号
+            Integer sourceId = detail.getPbd_slid();
+            //未核销金额
+            Double namount = new Double(0);
+            if(sourceId!=0){
+                Subledger subledger = subledgerMapper.selectByPrimaryKey(sourceId);
+                namount = subledger.getSl_namount();
+            }
+            //本次核销金额不能大于未核销金额
+            if(nowbalance>namount){
+                throw new BizException(500, BizExceptionCode.PAYBALANCE_OUTNOWBALANCE.getMessage());
+            }
+            //单据金额
+            Double amount = detail.getPbd_amount();
+            if(amount>0 && nowbalance<0){
+                String error = "单据类型为" + detail.getPbd_slkind() + "的单据,核销金额必须为正数";
+                throw new BizException(500, error);
+            }
+            if(amount<0 && nowbalance>0){
+                String error = "单据类型为" + detail.getPbd_slkind() + "的单据,核销金额必须为负数";
+                throw new BizException(500, error);
+            }
+        }
+        //不能选择重复的源单
+        for  ( int  i  =   0 ; i  <  paybalancedetail.size()  -   1 ; i ++ )  {
+            for  ( int  j  =  paybalancedetail.size()  -   1 ; j  >  i; j -- )  {
+                if  (paybalancedetail.get(j).getPbd_slcode().equals(paybalancedetail.get(i).getPbd_slcode()))  {
+                    throw new BizException(500, BizExceptionCode.PAYBALANCE_UNIQUESOURCECODE.getMessage());
+                }
+            }
+        }
+        //付款金额合计
+        Double amountTotal = new Double(0);
+        for (Paybalancedet det: paybalancedet) {
+            amountTotal = amountTotal + det.getPd_amount();
+        }
+        //更新本次预付款金额
+        Paybalance updatePay = new Paybalance();
+        updatePay.setId(paybalance.getId());
+        updatePay.setPb_preamount(amountTotal+paybalance.getPb_discounts()-nowbalanceTotal);
+        paybalanceMapper.updateByPrimaryKeySelective(updatePay);
+    }
 
     @Override
     public void audit(Pay pay) {
@@ -115,6 +176,19 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         }else {
             paybalanceMapper.updateByPrimaryKeySelective(paybalance);
         }
+
+        Paybalance updatePay = new Paybalance();
+        List<Paybalancedet> paybalancedet = pay.getItems1();
+        List<Paybalancedetail> paybalancedetail = pay.getItems2();
+        //更新主表付款金额:pb_pdamount=从表一金额合计
+        Double amountTotal = new Double(0);
+        for (Paybalancedet det: paybalancedet) {
+            amountTotal = amountTotal + det.getPd_amount();
+        }
+        updatePay.setId(pay.getMain().getId());
+        updatePay.setPb_pdamount(amountTotal);
+        //updateByPrimaryKeySelective
+
     }
 
     @Override
@@ -129,6 +203,13 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         paybalance = paybalanceMapper.selectByPrimaryKey(id);
         subledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
         banksubledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
+
+        //更新供应商资料
+        /**
+         * ve_preamount=nvl(ve_preamount,0)-pb_preamount,
+         * ve_payamount=nvl(ve_payamount,0)+pb_pbdamount,
+         * ve_leftamount=ve_beginapamount-e_beginprepayamount+ve_payamount-ve_preamount;
+         */
     }
 
 

+ 72 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java

@@ -56,6 +56,9 @@ public class RecbalanceServiceImpl implements RecbalanceService {
         //单号赋值
         recbalance.setRb_code(pu_code);
 
+        //校验数据
+        checkRecbalance(rec);
+
         Long rbId = recbalance.getId();
         if (rbId > 0){
             recbalanceMapper.updateByPrimaryKeySelective(recbalance);
@@ -93,6 +96,63 @@ public class RecbalanceServiceImpl implements RecbalanceService {
         return new DocBaseDTO(rbId, pu_code, BillCodeSeq.RECBALANCE.getCaller());
     }
 
+    /**
+     * 校验数据
+     * @param pay
+     */
+    private void checkRecbalance(Rec rec){
+        Recbalance recbalance = rec.getMain();
+        List<Recbalancedet> recbalancedet = rec.getItems1();
+        List<Recbalancedetail> recbalancedetail = rec.getItems2();
+        //本次核销合计
+        Double nowbalanceTotal = new Double(0);
+        for(Recbalancedetail detail : recbalancedetail){
+            //本次核销金额
+            Double nowbalance = detail.getRbd_nowbalance();
+            nowbalanceTotal = nowbalanceTotal + nowbalance;
+            //来源单号
+            Integer sourceId = detail.getRbd_slid();
+            //未核销金额
+            Double namount = new Double(0);
+            if(sourceId!=0){
+                Subledger subledger = subledgerMapper.selectByPrimaryKey(sourceId);
+                namount = subledger.getSl_namount();
+            }
+            //本次核销金额不能大于未核销金额
+            if(nowbalance>namount){
+                throw new BizException(500, BizExceptionCode.RECALANCE_OUTNOWBALANCE.getMessage());
+            }
+            //单据金额
+            Double amount = detail.getRbd_amount();
+            if(amount>0 && nowbalance<0){
+                String error = "单据类型为" + detail.getRbd_slkind() + "的单据,核销金额必须为正数";
+                throw new BizException(500, error);
+            }
+            if(amount<0 && nowbalance>0){
+                String error = "单据类型为" + detail.getRbd_slkind() + "的单据,核销金额必须为负数";
+                throw new BizException(500, error);
+            }
+        }
+        //不能选择重复的源单
+        for  ( int  i  =   0 ; i  <  recbalancedetail.size()  -   1 ; i ++ )  {
+            for  ( int  j  =  recbalancedetail.size()  -   1 ; j  >  i; j -- )  {
+                if  (recbalancedetail.get(j).getRbd_slcode().equals(recbalancedetail.get(i).getRbd_slcode()))  {
+                    throw new BizException(500, BizExceptionCode.PAYBALANCE_UNIQUESOURCECODE.getMessage());
+                }
+            }
+        }
+        //付款金额合计
+        Double amountTotal = new Double(0);
+        for (Recbalancedet det: recbalancedet) {
+            amountTotal = amountTotal + det.getRd_amount();
+        }
+        //更新本次预付款金额
+        Recbalance updatePay = new Recbalance();
+        updatePay.setId(recbalance.getId());
+        updatePay.setRb_preamount(amountTotal+recbalance.getRb_discounts()-nowbalanceTotal);
+        recbalanceMapper.updateByPrimaryKeySelective(updatePay);
+    }
+
     @Override
     public void delete(int id) {
         recbalanceMapper.deleteByPrimaryKey(id);
@@ -142,6 +202,18 @@ public class RecbalanceServiceImpl implements RecbalanceService {
         }else {
             recbalanceMapper.updateByPrimaryKeySelective(recbalance);
         }
+
+        Recbalance updatePay = new Recbalance();
+        List<Recbalancedet> recbalancedet = rec.getItems1();
+        List<Recbalancedetail> recbalancedetail = rec.getItems2();
+        //更新主表付款金额:pb_pdamount=从表一金额合计
+        Double amountTotal = new Double(0);
+        for (Recbalancedet det: recbalancedet) {
+            amountTotal = amountTotal + det.getRd_amount();
+        }
+        updatePay.setId(rec.getMain().getId());
+        updatePay.setRb_rdamount(amountTotal);
+        //updateByPrimaryKeySelective
     }
 
     @Override

+ 9 - 0
applications/money/money-server/src/main/resources/mapper/PaybalancedetailMapper.xml

@@ -234,4 +234,13 @@
     </set>
     where pbd_id = #{id,jdbcType=INTEGER}
   </update>
+  <!--<resultMap id="statistics_sourcecode" type="com.usoftchina.saas.money.po.PaybalanceSourceCode">-->
+    <!--<result column="countNum" property="countNum" jdbcType="INTEGER"></result>-->
+    <!--<result column="pbd_slcode" property="pbd_slcode" jdbcType="INTEGER"></result>-->
+  <!--</resultMap>-->
+  <!--<select id="checkPaybalanceDetailCodeUnique" resultMap="statistics_sourcecode" parameterType="java.lang.Long" >-->
+    <!--select count(1) as countNum,pbd_slcode from paybalancedetail-->
+    <!--where pbd_pbid = #{id,jdbcType=Long}-->
+    <!--GROUP BY pbd_slcode having count(1)>1-->
+  <!--</select>-->
 </mapper>

+ 18 - 9
frontend/saas-web/app/view/money/payBalance/FormPanel.js

@@ -51,7 +51,8 @@ Ext.define('saas.view.money.payBalance.FormPanel', {
     }, {
         xtype: "dbfindtrigger",
         name: "pb_vendname",
-        fieldLabel: "供应商名称"
+        fieldLabel: "供应商名称",
+        allowBlank : false
     },{
         xtype:"numberfield",
         name:"ve_leftamount",
@@ -74,11 +75,11 @@ Ext.define('saas.view.money.payBalance.FormPanel', {
         name: "pb_pbdamount",
         fieldLabel: "本次核销金额"
     }, {
-        xtype: "hidden",
+        xtype: "numberfield",
         name: "pb_preamount",
         fieldLabel: "本次预付款"
     }, {
-        xtype: 'hidden',
+        xtype: 'numberfield',
         name: 'pb_discounts',
         fieldLabel: '整单折扣'
     }, {
@@ -169,11 +170,6 @@ Ext.define('saas.view.money.payBalance.FormPanel', {
                 xtype: 'textfield'
             }
         }]
-    }, {
-        xtype:'dbfindtrigger',
-        columnWidth: 1,
-        fieldLabel:'选择源单',
-        name: 'choseSource'
     },{
         xtype: "detailGridField",
         storeModel: 'saas.model.money.PayBalance2',
@@ -194,7 +190,20 @@ Ext.define('saas.view.money.payBalance.FormPanel', {
             hidden: true
         }, {
             text: '来源单号',
-            dataIndex: 'pbd_slcode'
+            dataIndex: 'pbd_slcode',
+            editor:{
+                displayField : "display",
+                editable : true,
+                format : "",
+                hideTrigger : false,
+                maxLength : 100.0,
+                minValue : null,
+                positiveNum : false,
+                queryMode : "local",
+                store : null,
+                valueField : "value",
+                xtype : "multidbfindtrigger"
+            }
         }, {
             text: "业务类型",
             dataIndex: "pbd_slkind",

+ 1 - 1
frontend/saas-web/app/view/money/payBalance/FormPanelController.js

@@ -87,7 +87,7 @@ Ext.define('saas.view.money.payBalance.FormPanelController', {
 
                 }
             },
-            'dbfindtrigger[name=choseSource]': {
+            'multidbfindtrigger[name=pbd_slcode]': {
                 beforerender: function (f) {
                     Ext.apply(f, {
                         dataUrl: '/api/money/subledger/list',

+ 14 - 6
frontend/saas-web/app/view/money/recBalance/FormPanel.js

@@ -166,11 +166,6 @@ Ext.define('saas.view.money.recBalance.FormPanel', {
                 xtype: 'textfield'
             }
         }]
-    },{
-        xtype:'dbfindtrigger',
-        columnWidth: 1,
-        fieldLabel:'选择源单',
-        name: 'choseSource'
     },{
         xtype: "detailGridField",
         storeModel: 'saas.model.money.RecBalance2',
@@ -196,7 +191,20 @@ Ext.define('saas.view.money.recBalance.FormPanel', {
             hidden: true
         }, {
             text: '来源单号',
-            dataIndex: 'rbd_slcode'
+            dataIndex: 'rbd_slcode',
+            editor:{
+                displayField : "display",
+                editable : true,
+                format : "",
+                hideTrigger : false,
+                maxLength : 100.0,
+                minValue : null,
+                positiveNum : false,
+                queryMode : "local",
+                store : null,
+                valueField : "value",
+                xtype : "multidbfindtrigger"
+            }
         }, {
             text: "业务类型",
             dataIndex: "rbd_slkind"

+ 1 - 1
frontend/saas-web/app/view/money/recBalance/FormPanelController.js

@@ -154,7 +154,7 @@ Ext.define('saas.view.money.recBalance.FormPanelController', {
 
                 }
             },
-            'dbfindtrigger[name=choseSource]': {
+            'multidbfindtrigger[name=rbd_slcode]': {
                 beforerender: function (f) {
                     Ext.apply(f, {
                         dataUrl: '/api/money/subledger/list',