Browse Source

客户期初、供应商期初:在核销单中被使用不能删除

dingyl 6 years ago
parent
commit
bb56e08274

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/CustAramountMapper.java

@@ -39,4 +39,6 @@ public interface CustAramountMapper extends CommonBaseMapper<CustAramount> {
     void updateCodeAndNameByCustid(@Param("cu_id") Long cu_id);
 
     void deleteByCustid(@Param("cu_id") Long cu_id);
+
+    int checkVerification(@Param("cu_id") Long cu_id,@Param("currency") String currency);
 }

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/VendApamountMapper.java

@@ -37,4 +37,6 @@ public interface VendApamountMapper extends CommonBaseMapper<VendApamount> {
     void batchInsert(List<VendApamount> vendApamounts);
 
     void batchUpdate(List<VendApamount> vendApamounts);
+
+    int checkVerification(@Param("ve_id") Long ve_id,@Param("currency") String currency);
 }

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustAramountServiceImpl.java

@@ -90,6 +90,11 @@ public class CustAramountServiceImpl extends CommonBaseServiceImpl<CustAramountM
             if(checkBeginData > 0){
                 throw new BizException(BizExceptionCode.BIZ_NOPERIOD_DELETE);
             }
+            //已被核销,不能删除
+            int hasVerify=getMapper().checkVerification(custAramount.getCa_custid(),custAramount.getCa_currency());
+            if(hasVerify>0){
+                throw new BizException(BizExceptionCode.BIZ_RELDELETE);
+            }
             //删除中间表subledger数据
             String delcond="sl_kind='期初余额' and sl_currency='"+custAramount.getCa_currency()+"' and sl_custid='"+custAramount.getCa_custid()+"'"+
                     " and sl_ym="+ca_begindate;

+ 5 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendApamountServiceImpl.java

@@ -89,6 +89,11 @@ public class VendApamountServiceImpl extends CommonBaseServiceImpl<VendApamountM
             if(checkBeginData > 0){
                 throw new BizException(BizExceptionCode.BIZ_NOPERIOD_DELETE);
             }
+            //已被核销,不能删除
+            int hasVerify=getMapper().checkVerification(vendApamount.getVa_vendid(),vendApamount.getVa_currency());
+            if(hasVerify>0){
+                throw new BizException(BizExceptionCode.BIZ_RELDELETE);
+            }
             //删除中间表subledger数据
             String delcond="sl_kind='期初余额' and sl_currency='"+vendApamount.getVa_currency()+"' and sl_vendid='"+vendApamount.getVa_vendid()+"'"+
                     " and sl_ym="+va_begindate;

+ 7 - 0
applications/document/document-server/src/main/resources/mapper/CustAramountMapper.xml

@@ -368,4 +368,11 @@
         delete from custaramount
         where ca_custid = #{cu_id}
     </delete>
+    <select id="checkVerification" resultType="java.lang.Integer">
+        select count(1) from subledger
+        where sl_kind='期初余额' and sl_custid=#{cu_id} and sl_currency=#{currency}
+        and (ifnull(sl_yamount,0)!=0
+             or exists(select 1 from verificationdet where vd_slid=sl_id)
+             or exists(select 1 from verificationdetail where vcd_slid=sl_id))
+    </select>
 </mapper>

+ 7 - 1
applications/document/document-server/src/main/resources/mapper/VendApamountMapper.xml

@@ -368,5 +368,11 @@
             where va_id = #{item.id}
         </foreach>
     </update>
-
+    <select id="checkVerification" resultType="java.lang.Integer">
+        select count(1) from subledger
+        where sl_kind='期初余额' and sl_vendid=#{ve_id} and sl_currency=#{currency}
+        and (ifnull(sl_yamount,0)!=0
+             or exists(select 1 from verificationdet where vd_slid=sl_id)
+             or exists(select 1 from verificationdetail where vcd_slid=sl_id))
+    </select>
 </mapper>