Browse Source

资金模块-调整金额逻辑

huangx 7 years ago
parent
commit
3c267a8026

+ 20 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Bankinformation.java

@@ -43,6 +43,10 @@ public class Bankinformation extends CommonBaseEntity implements Serializable {
 
     private String bk_remark;
 
+    private Double bk_income;
+
+    private Double bk_spending;
+
     public String getBk_bankcode() {
         return bk_bankcode;
     }
@@ -186,4 +190,20 @@ public class Bankinformation extends CommonBaseEntity implements Serializable {
     public void setBk_remark(String bk_remark) {
         this.bk_remark = bk_remark;
     }
+
+    public Double getBk_income() {
+        return bk_income;
+    }
+
+    public void setBk_income(Double bk_income) {
+        this.bk_income = bk_income;
+    }
+
+    public Double getBk_spending() {
+        return bk_spending;
+    }
+
+    public void setBk_spending(Double bk_spending) {
+        this.bk_spending = bk_spending;
+    }
 }

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

@@ -192,14 +192,20 @@ public class PaybalanceServiceImpl implements PaybalanceService {
             //更新账户资料金额
             Bankinformation bankinformation = new Bankinformation();
             Bankinformation nowBankInformation = paybalanceMapper.selectBankInformationByPrimaryKey(det.getPd_bankid());
-            bankinformation.setBk_thisamount((nowBankInformation.getBk_thisamount() == null ? new Double(0) : nowBankInformation.getBk_thisamount())
-                    + (det.getPd_amount() == null ? 0.0 : det.getPd_amount()));
+            Double amount = det.getPd_amount() == null ? new Double(0) : det.getPd_amount();
+            Double preamount = nowBankInformation.getBk_beginamount() ==null ? new Double(0):nowBankInformation.getBk_beginamount();//期初金额
+            Double incoming = nowBankInformation.getBk_income() ==null ? new Double(0):nowBankInformation.getBk_income();
+            Double spending = nowBankInformation.getBk_spending() ==null ? new Double(0):nowBankInformation.getBk_spending();
+            bankinformation.setBk_spending(spending+amount);
+            bankinformation.setBk_thisamount(preamount+incoming-(spending+amount));
+            bankinformation.setId(Long.valueOf(String.valueOf(det.getPd_bankid())));
             paybalanceMapper.updateBankByPrimaryKeySelective(bankinformation);
+
         }
         //更新主表pb_pbdamount=从表二金额合计
         Double amountTotal2 = new Double(0);
         for (Paybalancedetail detail : paybalancedetail){
-            amountTotal2 = amountTotal2 + detail.getPbd_amount();
+            amountTotal2 = amountTotal2 + detail.getPbd_nowbalance();
         }
         updatePay.setId(pay.getMain().getId());
         updatePay.setPb_pdamount(amountTotal);
@@ -218,20 +224,25 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         Double payamount = vendorData.getVe_payamount()==null?new Double(0):vendorData.getVe_payamount();
 
         Vendor vendor = new Vendor();
+        Double recbalancePreamount = paybalance.getPb_preamount();
         vendor.setId(Long.valueOf(String.valueOf(paybalance.getPb_vendid())));
-        vendor.setVe_preamount(preamount+amountTotal);
+        vendor.setVe_preamount(preamount+recbalancePreamount);
         vendor.setVe_payamount(payamount-amountTotal2);
-        vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-amountTotal2-preamount-amountTotal);
+        vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-amountTotal2-preamount-recbalancePreamount);
         paybalanceMapper.updateVendorByPrimaryKeySelective(vendor);
 
         for (Paybalancedetail detail: paybalancedetail) {
-            Subledger newsubledger = new Subledger();
+            Subledger subledger1 = new Subledger();
             Subledger nowSubledger = subledgerMapper.selectByPrimaryKey(detail.getPbd_slid());
-            newsubledger.setId(Long.valueOf(String.valueOf(detail.getPbd_slid())));
-            newsubledger.setSl_yamount(detail.getPbd_nowbalance()+nowSubledger.getSl_yamount());//已核销
-            newsubledger.setSl_namount(nowSubledger.getSl_namount()-detail.getPbd_nowbalance());//未核销
-            subledgerMapper.updateByPrimaryKeySelective(newsubledger);
+            subledger1.setId(Long.valueOf(String.valueOf(detail.getPbd_slid())));
+            Double yamount = nowSubledger.getSl_yamount()==null?new Double(0):nowSubledger.getSl_yamount();
+            Double namount = nowSubledger.getSl_namount()==null?new Double(0):nowSubledger.getSl_namount();
+            Double nowBalance = detail.getPbd_nowbalance()==null?new Double(0):detail.getPbd_nowbalance();
+            subledger1.setSl_yamount(yamount+nowBalance);//已核销
+            subledger1.setSl_namount(namount-nowBalance);//未核销
+            subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
+
     }
 
     @Override
@@ -260,10 +271,16 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         //更新账户资料金额
         List<Paybalancedet> paybalancedet = paybalancedetMapper.selectByPrimaryKey(id);
         for (Paybalancedet det:paybalancedet) {
+            //更新账户资料金额
             Bankinformation bankinformation = new Bankinformation();
             Bankinformation nowBankInformation = paybalanceMapper.selectBankInformationByPrimaryKey(det.getPd_bankid());
-            bankinformation.setBk_thisamount((nowBankInformation.getBk_thisamount() == null ? new Double(0) : nowBankInformation.getBk_thisamount())
-                    - (det.getPd_amount() == null ? new Double(0) : det.getPd_amount()));
+            Double amount = det.getPd_amount() == null ? new Double(0) : det.getPd_amount();
+            Double bkpreamount = nowBankInformation.getBk_beginamount() ==null ? new Double(0):nowBankInformation.getBk_beginamount();//期初金额
+            Double bkincoming = nowBankInformation.getBk_income() ==null ? new Double(0):nowBankInformation.getBk_income();
+            Double bkspending = nowBankInformation.getBk_spending() ==null ? new Double(0):nowBankInformation.getBk_spending();
+            bankinformation.setBk_spending(bkspending-amount);
+            bankinformation.setBk_thisamount(bkpreamount+bkincoming-(bkspending-amount));
+            bankinformation.setId(Long.valueOf(String.valueOf(det.getPd_bankid())));
             paybalanceMapper.updateBankByPrimaryKeySelective(bankinformation);
         }
 
@@ -272,8 +289,11 @@ public class PaybalanceServiceImpl implements PaybalanceService {
             Subledger subledger1 = new Subledger();
             Subledger nowSubledger = subledgerMapper.selectByPrimaryKey(detail.getPbd_slid());
             subledger1.setId(Long.valueOf(String.valueOf(detail.getPbd_slid())));
-            subledger1.setSl_yamount(nowSubledger.getSl_yamount()-detail.getPbd_nowbalance());//已核销
-            subledger1.setSl_namount(nowSubledger.getSl_namount()+detail.getPbd_nowbalance());//未核销
+            Double yamount = nowSubledger.getSl_yamount()==null?new Double(0):nowSubledger.getSl_yamount();
+            Double namount = nowSubledger.getSl_namount()==null?new Double(0):nowSubledger.getSl_namount();
+            Double nowBalance = detail.getPbd_nowbalance()==null?new Double(0):detail.getPbd_nowbalance();
+            subledger1.setSl_yamount(yamount-nowBalance);//已核销
+            subledger1.setSl_namount(namount+nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
 

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

@@ -218,7 +218,13 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             //更新账户资料金额
             Bankinformation bankinformation = new Bankinformation();
             Bankinformation nowBankInformation = recbalanceMapper.selectBankInformationByPrimaryKey(det.getRd_bankid());
-            bankinformation.setBk_thisamount(nowBankInformation.getBk_thisamount()+det.getRd_amount());
+            Double amount = det.getRd_amount() == null ? new Double(0) : det.getRd_amount();
+            Double preamount = nowBankInformation.getBk_beginamount() ==null ? new Double(0):nowBankInformation.getBk_beginamount();//期初金额
+            Double incoming = nowBankInformation.getBk_income() ==null ? new Double(0):nowBankInformation.getBk_income();
+            Double spending = nowBankInformation.getBk_spending() ==null ? new Double(0):nowBankInformation.getBk_spending();
+            bankinformation.setBk_income(incoming+amount);
+            bankinformation.setBk_thisamount(preamount+(incoming+amount)-spending);
+            bankinformation.setId(Long.valueOf(String.valueOf(det.getRd_bankid())));
             recbalanceMapper.updateBankByPrimaryKeySelective(bankinformation);
         }
         //更新主表pb_pbdamount=从表二金额合计
@@ -243,11 +249,12 @@ public class RecbalanceServiceImpl implements RecbalanceService {
         Double recamount = customerData.getCu_recamount()==null?new Double(0):customerData.getCu_recamount();
 
         Customer customer = new Customer();
+        Double paybalancePreamount = recbalance.getRb_preamount();
         customer.setId(Long.valueOf(String.valueOf(recbalance.getRb_custid())));
         customer.setId(Long.valueOf(String.valueOf(recbalance.getRb_custid())));
-        customer.setCu_preamount(preamount+amountTotal);
+        customer.setCu_preamount(preamount+paybalancePreamount);
         customer.setCu_recamount(recamount-amountTotal2);
-        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amountTotal2-preamount-amountTotal);
+        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amountTotal2-preamount-paybalancePreamount);
         recbalanceMapper.updateCustomerByPrimaryKeySelective(customer);
 
         //更新本次核销金额
@@ -255,8 +262,11 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             Subledger subledger1 = new Subledger();
             Subledger nowSubledger = subledgerMapper.selectByPrimaryKey(detail.getRbd_slid());
             subledger1.setId(Long.valueOf(String.valueOf(detail.getRbd_slid())));
-            subledger1.setSl_yamount(detail.getRbd_nowbalance() + nowSubledger.getSl_yamount());//已核销
-            subledger1.setSl_namount(nowSubledger.getSl_namount() - detail.getRbd_nowbalance());//未核销
+            Double yamount = nowSubledger.getSl_yamount()==null?new Double(0):nowSubledger.getSl_yamount();
+            Double namount = nowSubledger.getSl_namount()==null?new Double(0):nowSubledger.getSl_namount();
+            Double nowBalance = detail.getRbd_nowbalance()==null?new Double(0):detail.getRbd_nowbalance();
+            subledger1.setSl_yamount(yamount+nowBalance);//已核销
+            subledger1.setSl_namount(namount-nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
     }
@@ -287,9 +297,16 @@ public class RecbalanceServiceImpl implements RecbalanceService {
         //更新账户资料金额
         List<Recbalancedet> recbalancedet = recbalancedetMapper.selectByPrimaryKey(Math.toIntExact(id));
         for (Recbalancedet det:recbalancedet) {
+            //更新账户资料金额
             Bankinformation bankinformation = new Bankinformation();
             Bankinformation nowBankInformation = recbalanceMapper.selectBankInformationByPrimaryKey(det.getRd_bankid());
-            bankinformation.setBk_thisamount(nowBankInformation.getBk_thisamount()-det.getRd_amount());
+            Double amount = det.getRd_amount() == null ? new Double(0) : det.getRd_amount();
+            Double bkpreamount = nowBankInformation.getBk_beginamount() ==null ? new Double(0):nowBankInformation.getBk_beginamount();//期初金额
+            Double bkincoming = nowBankInformation.getBk_income() ==null ? new Double(0):nowBankInformation.getBk_income();
+            Double bkspending = nowBankInformation.getBk_spending() ==null ? new Double(0):nowBankInformation.getBk_spending();
+            bankinformation.setBk_income(bkincoming-amount);
+            bankinformation.setBk_thisamount(bkpreamount+(bkincoming-amount)-bkspending);
+            bankinformation.setId(Long.valueOf(String.valueOf(det.getRd_bankid())));
             recbalanceMapper.updateBankByPrimaryKeySelective(bankinformation);
         }
 
@@ -310,9 +327,11 @@ public class RecbalanceServiceImpl implements RecbalanceService {
         for(Recbalancedetail detail: recbalancedetail) {
             Subledger subledger1 = new Subledger();
             Subledger nowSubledger = subledgerMapper.selectByPrimaryKey(detail.getRbd_slid());
-            subledger1.setId(Long.valueOf(String.valueOf(detail.getRbd_slid())));
-            subledger1.setSl_yamount(nowSubledger.getSl_yamount()-detail.getRbd_nowbalance());//已核销
-            subledger1.setSl_namount(nowSubledger.getSl_namount()+detail.getRbd_nowbalance());//未核销
+            subledger1.setId(Long.valueOf(String.valueOf(detail.getRbd_slid())));Double yamount = nowSubledger.getSl_yamount()==null?new Double(0):nowSubledger.getSl_yamount();
+            Double namount = nowSubledger.getSl_namount()==null?new Double(0):nowSubledger.getSl_namount();
+            Double nowBalance = detail.getRbd_nowbalance()==null?new Double(0):detail.getRbd_nowbalance();
+            subledger1.setSl_yamount(yamount-nowBalance);//已核销
+            subledger1.setSl_namount(namount+nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
     }

+ 9 - 1
applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml

@@ -458,7 +458,7 @@
   <sql id="Bank_Column_List" >
     bk_id, bk_bankcode, bk_bankname, bk_date, bk_type, bk_beginamount, bk_thisamount,
     bk_status, bk_statuscode, bk_recorderid, bk_recorder, bk_recorddate, bk_ym, companyid,
-    updaterId, updateTime, bk_text1, bk_text2, bk_text3, bk_text4, bk_text5, bk_remark
+    updaterId, updateTime, bk_text1, bk_text2, bk_text3, bk_text4, bk_text5, bk_remark,bk_spending,bk_income
   </sql>
   <sql id="Blob_Column_List" >
     bk_remark
@@ -497,6 +497,8 @@
     <result column="bk_text4" property="bk_text4" jdbcType="VARCHAR" />
     <result column="bk_text5" property="bk_text5" jdbcType="VARCHAR" />
     <result column="bk_remark" property="bk_remark" jdbcType="VARCHAR" />
+    <result column="bk_spending" property="bk_spending" jdbcType="DOUBLE" />
+    <result column="bk_income" property="bk_income" jdbcType="DOUBLE" />
   </resultMap>
   <update id="updateBankByPrimaryKeySelective" parameterType="com.usoftchina.saas.money.po.Bankinformation" >
     update bankinformation
@@ -564,6 +566,12 @@
       <if test="bk_remark != null" >
         bk_remark = #{bk_remark,jdbcType=LONGVARCHAR},
       </if>
+      <if test="bk_spending != null" >
+        bk_spending = #{bk_spending,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_income != null" >
+        bk_income = #{bk_income,jdbcType=DOUBLE},
+      </if>
     </set>
     where bk_id = #{id,jdbcType=INTEGER}
   </update>

+ 9 - 1
applications/money/money-server/src/main/resources/mapper/RecbalanceMapper.xml

@@ -591,7 +591,7 @@
   <sql id="Bank_Column_List" >
     bk_id, bk_bankcode, bk_bankname, bk_date, bk_type, bk_beginamount, bk_thisamount,
     bk_status, bk_statuscode, bk_recorderid, bk_recorder, bk_recorddate, bk_ym, companyid,
-    updaterId, updateTime, bk_text1, bk_text2, bk_text3, bk_text4, bk_text5, bk_remark
+    updaterId, updateTime, bk_text1, bk_text2, bk_text3, bk_text4, bk_text5, bk_remark,bk_spending,bk_income
   </sql>
   <sql id="Blob_Column_List" >
     bk_remark
@@ -630,6 +630,8 @@
     <result column="bk_text4" property="bk_text4" jdbcType="VARCHAR" />
     <result column="bk_text5" property="bk_text5" jdbcType="VARCHAR" />
     <result column="bk_remark" property="bk_remark" jdbcType="VARCHAR" />
+    <result column="bk_spending" property="bk_spending" jdbcType="DOUBLE" />
+    <result column="bk_income" property="bk_income" jdbcType="DOUBLE" />
   </resultMap>
   <update id="updateBankByPrimaryKeySelective" parameterType="com.usoftchina.saas.money.po.Bankinformation" >
     update bankinformation
@@ -697,6 +699,12 @@
       <if test="bk_remark != null" >
         bk_remark = #{bk_remark,jdbcType=LONGVARCHAR},
       </if>
+      <if test="bk_spending != null" >
+        bk_spending = #{bk_spending,jdbcType=DOUBLE},
+      </if>
+      <if test="bk_income != null" >
+        bk_income = #{bk_income,jdbcType=DOUBLE},
+      </if>
     </set>
     where bk_id = #{id,jdbcType=INTEGER}
   </update>

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

@@ -91,83 +91,6 @@ Ext.define('saas.view.money.recBalance.FormPanelController', {
 
                 }
             },
-            'dbfindtrigger[name=rd_bankname]':{
-                beforerender:function(f){
-                    Ext.apply(f,{
-                        //数据接口
-                        dataUrl: '/api/document/customer/list',
-                        addXtype: 'document-customer-formpanel',
-                        addTitle: '客户资料',
-                        //赋值 
-                        dbfinds:[{
-                            from: 'id', to: 'rb_custid'
-                        }, {
-                            from:'cu_code', to:'rb_custcode'
-                        },{
-                            from:'cu_name', to:'rb_custname'
-                        }],
-                        //联想设置
-                        dbtpls:[{
-                            field:'cu_code',width:100
-                        },{
-                            field:'cu_name',width:100
-                        }],
-                        //联想查询条件
-                        defaultCondition: 'cu_statuscode="OPEN"',
-                        //放大镜窗口字段
-                        dbSearchFields:[{
-                            emptyText:'输入客户编号或名称',
-                            name : "cu_name", 
-                            getCondition: function(v) {
-                                return "(upper(cu_code) like '%"+v.toUpperCase()+"%' or upper(cu_name) like '%"+v.toUpperCase()+"%')";
-                            },
-                            fieldLabel : "客户名称", 
-                            columnWidth : 0.25
-                        }],
-                        //放大镜窗口列表
-                        dbColumns:[{
-                            "text": "客户ID",
-                            "hidden": true,
-                            "dataIndex": "id",
-                        },{
-                            "text": "客户编号",
-                            "dataIndex": "cu_code",
-                            "width": 200,
-                        }, {
-                            "text": "客户名称",
-                            "dataIndex": "cu_name",
-                            "width": 200
-                        },{
-                            "text": "客户类型",
-                            "dataIndex": "cu_name",
-                            "width": 100
-                        },{
-                            "text": "业务员",
-                            "dataIndex": "cu_sellername",
-                            "width": 100
-                        },{
-                            "text": "税率",
-                            "dataIndex": "cu_taxrate",
-                            "width": 100,
-                            xtype: 'numbercolumn',
-                            align:'end'
-                        },{
-                            "text": "承付天数",
-                            "dataIndex": "cu_promisedays",
-                            "width": 100,
-                            xtype: 'numbercolumn',
-                            align:'end'
-                        },{
-                            "text": "额度",
-                            "dataIndex": "cu_credit",
-                            "width": 100,
-                            xtype: 'numbercolumn',
-                            align:'end'
-                        }]
-                    }) ;   
-
-                }
-            },
             'multidbfindtrigger[name=rbd_slcode]': {
                 beforerender: function (f) {
                     Ext.apply(f, {