Browse Source

核销单:应收转应收、应付转应付修改

dingyl 6 years ago
parent
commit
90b0c2c4e8

+ 10 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/controller/SubledgerController.java

@@ -1,8 +1,10 @@
 package com.usoftchina.saas.money.controller;
 package com.usoftchina.saas.money.controller;
 
 
+import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.base.Result;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
 import com.usoftchina.saas.money.mapper.SubledgerMapper;
 import com.usoftchina.saas.money.mapper.SubledgerMapper;
+import com.usoftchina.saas.money.po.VerificationList;
 import com.usoftchina.saas.money.service.SubledgerService;
 import com.usoftchina.saas.money.service.SubledgerService;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,4 +26,12 @@ public class SubledgerController {
     public Result getListData(PageRequest page, ListReqDTO condition){
     public Result getListData(PageRequest page, ListReqDTO condition){
         return Result.success(subledgerService.seleteList(page, condition));
         return Result.success(subledgerService.seleteList(page, condition));
     }
     }
+
+    /**
+     * 核销单明细1放大镜特殊处理--应收转应收、应付转应付
+     */
+    @RequestMapping("/dbfindlist")
+    public Result getDbfindlistData(PageRequest page, ListReqDTO condition) {
+        return Result.success(subledgerService.getDbfindlistData(page, condition));
+    }
 }
 }

+ 2 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/SubledgerMapper.java

@@ -32,4 +32,6 @@ public interface SubledgerMapper {
 
 
     void updateProdInOut(@Param("companyid") Long companyid , @Param("code") String code , @Param("kind") String kind ,
     void updateProdInOut(@Param("companyid") Long companyid , @Param("code") String code , @Param("kind") String kind ,
                          @Param("status") String status , @Param("statuscode") String statuscode);
                          @Param("status") String status , @Param("statuscode") String statuscode);
+
+    List<Subledger>  selectSubledgerSpeBycondition(@Param("con") String con, @Param("companyId") Long companyId);
 }
 }

+ 1 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/SubledgerService.java

@@ -11,4 +11,5 @@ import com.usoftchina.saas.page.PageRequest;
  **/
  **/
 public interface SubledgerService {
 public interface SubledgerService {
     PageInfo<Subledger> seleteList(PageRequest page, ListReqDTO reqDTO);
     PageInfo<Subledger> seleteList(PageRequest page, ListReqDTO reqDTO);
+    PageInfo<Subledger> getDbfindlistData(PageRequest page, ListReqDTO reqDTO);
 }
 }

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

@@ -52,4 +52,28 @@ public class SubledgerServiceImpl implements SubledgerService {
         subledgerList = subledgerMapper.selectSubledgerBycondition(con, companyId);
         subledgerList = subledgerMapper.selectSubledgerBycondition(con, companyId);
         return subledgerList;
         return subledgerList;
     }
     }
+
+    @Override
+    public PageInfo<Subledger> getDbfindlistData(PageRequest page, ListReqDTO reqDTO) {
+        //设置默认分页
+        if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
+            page = new PageRequest();
+            page.setNumber(1);
+            page.setSize(10);
+        }
+        PageHelper.startPage(page.getNumber(), page.getSize());
+        List<Subledger> subledgerList = null;
+        Long companyId = BaseContextHolder.getCompanyId();
+        if (StringUtils.isEmpty(reqDTO)) {
+            return  null;
+        }
+        String con = reqDTO.getFinalCondition();
+        if (null == con) {
+            con = "1=1";
+        }
+        subledgerList = subledgerMapper.selectSubledgerSpeBycondition(con, companyId);
+        //取分页信息
+        PageInfo<Subledger> pageInfo = new PageInfo<Subledger>(subledgerList);
+        return pageInfo;
+    }
 }
 }

+ 37 - 27
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/VerificationServiceImpl.java

@@ -212,36 +212,47 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
 
 
         String type = main.getVc_kind();
         String type = main.getVc_kind();
         type = transferKind(type);
         type = transferKind(type);
+
+        for(Verificationdet det : items1){
+            //本次核销金额
+            Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
+            //单据金额
+            Double amount = det.getSl_namount();
+            //已核销金额
+            Double namount = det.getSl_namount()==null?new Double(0):det.getSl_namount();
+            //核销金额
+            if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
+                String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
+                int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
+                String error = String.format(msg, det.getVd_slkind());
+                throw new BizException(code, error);
+            }
+            if(amount.doubleValue()<0 && nowbalanceDet.doubleValue()>0){
+                String msg = BizExceptionCode.MONEY_NOWAMOUNT_NEGATIVE.getMessage();
+                int code = BizExceptionCode.MONEY_NOWAMOUNT_NEGATIVE.getCode();
+                String error = String.format(msg, det.getVd_slkind());
+                throw new BizException(code, error);
+            }
+            Double nowbalance = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
+            if( Math.abs(namount.doubleValue()) <  Math.abs(nowbalanceDet.doubleValue()) ){
+                throw new BizException(500, BizExceptionCode.RECALANCE_OUTNOWBALANCE.getMessage());
+            }
+        }
         if(type.equals("receipts_offset_receivable") || type.equals("prepaid_offset_payable") ||
         if(type.equals("receipts_offset_receivable") || type.equals("prepaid_offset_payable") ||
-                type.equals("receivable_offset_payable")){
+                type.equals("receivable_offset_payable")){//预收冲应收、预付冲应付、应收冲应付
             Double total1 = new Double(0);
             Double total1 = new Double(0);
             for(Verificationdet det : items1){
             for(Verificationdet det : items1){
                 Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
                 Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
                 total1 += nowbalanceDet;
                 total1 += nowbalanceDet;
-
-                //单据金额
-                Double amount = det.getSl_namount();
-                //核销金额
-                if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
-                    String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
-                    int code = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getCode();
-                    String error = String.format(msg, det.getVd_slkind());
-                    throw new BizException(code, error);
-                }
-                if(amount.doubleValue()<0 && nowbalanceDet.doubleValue()>0){
-                    String msg = BizExceptionCode.MONEY_NOWAMOUNT_NEGATIVE.getMessage();
-                    int code = BizExceptionCode.MONEY_NOWAMOUNT_NEGATIVE.getCode();
-                    String error = String.format(msg, det.getVd_slkind());
-                    throw new BizException(code, error);
-                }
             }
             }
             Double total2 = new Double(0);
             Double total2 = new Double(0);
             for(Verificationdetail detail : items2){
             for(Verificationdetail detail : items2){
                 Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
                 Double nowbalanceDet = detail.getVcd_nowbalance()==null?new Double(0):detail.getVcd_nowbalance();
                 total2 += nowbalanceDet;
                 total2 += nowbalanceDet;
-
                 //单据金额
                 //单据金额
                 Double amount = detail.getVcd_amount();
                 Double amount = detail.getVcd_amount();
+                //已核销金额
+                Double namount = detail.getSl_namount()==null?new Double(0):detail.getSl_namount();
                 //核销金额
                 //核销金额
                 if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
                 if(amount.doubleValue()>0 && nowbalanceDet.doubleValue()<0){
                     String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
                     String msg = BizExceptionCode.MONEY_NOWAMOUNT_POSITIVE.getMessage();
@@ -255,20 +266,14 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
                     String error = String.format(msg, detail.getVcd_slkind());
                     String error = String.format(msg, detail.getVcd_slkind());
                     throw new BizException(code, error);
                     throw new BizException(code, error);
                 }
                 }
+                if( Math.abs(namount.doubleValue()) <  Math.abs(nowbalanceDet.doubleValue()) ){
+                    throw new BizException(500, BizExceptionCode.RECALANCE_OUTNOWBALANCE.getMessage());
+                }
             }
             }
             if(total1.doubleValue()!=total2.doubleValue()){
             if(total1.doubleValue()!=total2.doubleValue()){
                 throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
                 throw new BizException(500, BizExceptionCode.VERIFICATION_CHECK_BALANCE.getMessage());
             }
             }
-        }else if(type.equals("receivable_to_receivable") || type.equals("payable_to_payable")){
-            for(Verificationdet det : items1){
-                Double namount = det.getSl_namount()==null?new Double(0):det.getSl_namount();
-                Double nowbalance = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
-                if(namount.doubleValue()<nowbalance.doubleValue()){
-                    throw new BizException(500, BizExceptionCode.RECALANCE_OUTNOWBALANCE.getMessage());
-                }
-            }
         }
         }
-
     }
     }
 
 
     //插入中间表
     //插入中间表
@@ -590,6 +595,11 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
             if(items1!=null){
             if(items1!=null){
                 for(VerificationdetDTO det : items1){
                 for(VerificationdetDTO det : items1){
                     Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
                     Double nowbalanceDet = det.getVd_nowbalance()==null?new Double(0):det.getVd_nowbalance();
+                    Subledger sub = subledgerMapper.selectByPrimaryKey(Math.toIntExact(det.getVd_slid()));
+                    if (sub != null && sub.getSl_preamount() != 0 &&
+                            ("receivable_to_receivable".equals(verificationDTO.getVc_kind()) || "payable_to_payable".equals(verificationDTO.getVc_kind()))) {
+                        nowbalanceDet=-1*nowbalanceDet;
+                    }
                     updateAuditSubledeger(det.getVd_slid(),nowbalanceDet);
                     updateAuditSubledeger(det.getVd_slid(),nowbalanceDet);
                 }
                 }
             }
             }

+ 17 - 0
applications/money/money-server/src/main/resources/mapper/SubledgerMapper.xml

@@ -275,4 +275,21 @@
     update prodinout set pi_prstatuscode=#{statuscode},pi_prstatus=#{status} where
     update prodinout set pi_prstatuscode=#{statuscode},pi_prstatus=#{status} where
     companyid=#{companyid} and pi_class=#{kind} and pi_inoutno=#{code}
     companyid=#{companyid} and pi_class=#{kind} and pi_inoutno=#{code}
   </update>
   </update>
+
+  <select id="selectSubledgerSpeBycondition" resultMap="BaseResultMap">
+    select sl_id,sl_kind,sl_code,sl_custid,sl_vendid,sl_date,
+    (case when ifnull(sl_preamount,0)!=0 then ifnull(sl_orderamount,0)*(-1)  else sl_orderamount end ) as sl_orderamount,
+    (case when ifnull(sl_preamount,0)!=0 then ifnull(sl_yamount,0)*(-1)  else sl_yamount end ) as sl_yamount,
+    (case when ifnull(sl_preamount,0)!=0 then ifnull(sl_namount,0)*(-1)  else sl_namount end ) as sl_namount,
+    sl_remark,companyid,sl_ym,sl_currency
+    from subledger
+    <where>
+      <if test="con != null">
+        ${con}
+      </if>
+      <if test="companyId != null">
+        and   subledger.companyId = #{companyId}
+      </if>
+    </where>  order by sl_date desc
+  </select>
 </mapper>
 </mapper>

+ 3 - 2
applications/money/money-server/src/main/resources/mapper/VerificationdetMapper.xml

@@ -481,8 +481,9 @@
   <select id="selectByFK" parameterType="long" resultMap="BaseResultMap">
   <select id="selectByFK" parameterType="long" resultMap="BaseResultMap">
     select
     select
     <include refid="Base_Column_List" />,
     <include refid="Base_Column_List" />,
-    <include refid="subledger_Column_List" />
-    from verificationdet left join subledger on sl_id=vd_slid and subledger.companyid=verificationdet.companyId
+    (case when vc_kind in ('应收转应收','应付转应付') and ifnull(sl_preamount,0)!=0 then sl_yamount*(-1) else sl_yamount end) as sl_yamount,
+    (case when vc_kind in ('应收转应收','应付转应付') and ifnull(sl_preamount,0)!=0 then sl_namount*(-1) else sl_namount end) as sl_namount
+    from verificationdet left join subledger on sl_id=vd_slid and subledger.companyid=verificationdet.companyId left join verification on verificationdet.vd_vcid=vc_id
       where vd_vcid=#{vc_id} order by vd_id
       where vd_vcid=#{vc_id} order by vd_id
   </select>
   </select>