Browse Source

基础资料-期间判断

huangx 7 years ago
parent
commit
94e5c6b44c

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

@@ -47,6 +47,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
     ACCOUNT_EXISTS(79505, "账号已存在"),
     DEAL_FAILED(79800, "编号:<u>%s</u>处理失败,%s"),
     USING_EXISTS(79504, ""),
+    LIMIT_PERIOD_VENDOR(79505,"修改供应商失败!不能修改系统结账期间%s之前的供应商的期初"),
+    LIMIT_PERIOD_CUSTOMER(79506,"修改客户失败!不能修改系统结账期间%s之前的供应商的期初"),
 
     VENDOR_ISCLOSE(79505, "供应商已关闭"),
     PRODUCT_ISCLOSE(79506, "物料已关闭"),

+ 4 - 2
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/SubledgerMapper.java

@@ -26,14 +26,16 @@ public interface SubledgerMapper {
     List<Subledger> selectSubledgerBycondition(@Param("con") String con, @Param("companyId") Long companyId);
 
     Long selectByKindCodeCustid(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
-                                     @Param("sl_custid") Integer sl_custid ,@Param("companyid") Long companyid);
+                                     @Param("sl_custid") Integer sl_custid ,@Param("companyid") Long companyid,@Param("sl_ym") String sl_ym);
 
     Long selectByKindCodeVendid(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
-                                     @Param("sl_vendid") Integer sl_vendid ,@Param("companyid") Long companyid);
+                                     @Param("sl_vendid") Integer sl_vendid ,@Param("companyid") Long companyid,@Param("sl_ym") String sl_ym);
 
     void deleteCustomer(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
                         @Param("sl_custid") Integer sl_custid);
 
     void deleteVendor(@Param("sl_code") String sl_code, @Param("sl_kind") String sl_kind,
                         @Param("sl_vendid") Integer sl_vendid);
+
+    String selectUnPeriod(@Param("companyId") Long companyId);
 }

+ 15 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/CustomerServiceImpl.java

@@ -134,6 +134,20 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         Double preamount = main.getCu_preamount()==null? new Double(0):main.getCu_preamount();
         customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-preamount);
 
+        //获取已结账的期间
+        String YM = subledgerMapper.selectUnPeriod(companyId);
+        if(YM==null || YM.equals("")){
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
+            YM = simpleDateFormat.format(main.getCu_begindate());
+        }else{
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
+            String beginDate = simpleDateFormat.format(main.getCu_begindate());
+            if(Integer.valueOf(YM)>Integer.valueOf(beginDate)){
+                int code = BizExceptionCode.LIMIT_PERIOD_CUSTOMER.getCode();
+                String mes = String.format(BizExceptionCode.LIMIT_PERIOD_CUSTOMER.getMessage(),YM);
+                throw new BizException(code , mes);
+            }
+        }
         //编号校验
         cu_code = RegexpUtils.replaceSpecCharacter(cu_code);
         cu_code = pushMaxnubmer(cu_code, cu_id);
@@ -284,7 +298,7 @@ public class CustomerServiceImpl extends CommonBaseServiceImpl<CustomerMapper, C
         subledger.setSl_namount(Math.abs(amount));
 
         Long sl_id  = subledgerMapper.selectByKindCodeCustid("期初余额","期初余额",
-                Math.toIntExact(customer.getId()),BaseContextHolder.getCompanyId());
+                Math.toIntExact(customer.getId()),BaseContextHolder.getCompanyId(),YM);
         subledger.setId(sl_id);
         if ( sl_id!=null && sl_id > 0 ) {
             subledgerMapper.updateByPrimaryKeySelective(subledger);

+ 16 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/VendorServiceImpl.java

@@ -119,6 +119,21 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
         main.setCompanyId(BaseContextHolder.getCompanyId());
         List<Vendorcontact> items = vendorListDTO.getItems();
         String ve_code = main.getVe_code().trim().toUpperCase();
+
+        //获取已结账的期间
+        String YM = subledgerMapper.selectUnPeriod(companyId);
+        if(YM==null || YM.equals("")){
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
+            YM = simpleDateFormat.format(main.getVe_begindate());
+        }else{
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");
+            String beginDate = simpleDateFormat.format(main.getVe_begindate());
+            if(Integer.valueOf(YM)>Integer.valueOf(beginDate)){
+                int code = BizExceptionCode.LIMIT_PERIOD_VENDOR.getCode();
+                String mes = String.format(BizExceptionCode.LIMIT_PERIOD_VENDOR.getMessage(),YM);
+                throw new BizException(code , mes);
+            }
+        }
         ve_code = RegexpUtils.replaceSpecCharacter(ve_code);
         String code = pushMaxnubmer(ve_code, main.getId());
         if(main.getId() == 0){
@@ -237,7 +252,7 @@ public class VendorServiceImpl extends CommonBaseServiceImpl<VendorMapper, Vendo
         subledger.setSl_orderamount(Math.abs(amount));
         subledger.setSl_namount(Math.abs(amount));
         Long sl_id = subledgerMapper.selectByKindCodeVendid("期初余额","期初余额",
-                Math.toIntExact(main.getId()),BaseContextHolder.getCompanyId());
+                Math.toIntExact(main.getId()),BaseContextHolder.getCompanyId(),YM);
         subledger.setId(sl_id);
         if ( sl_id!=null && sl_id > 0 ) {
             subledgerMapper.updateByPrimaryKeySelective(subledger);

+ 6 - 0
applications/document/document-server/src/main/resources/mapper/SubledgerMapper.xml

@@ -253,6 +253,7 @@
   from subledger
   where sl_code = #{sl_code,jdbcType=VARCHAR} and sl_kind = #{sl_kind,jdbcType=VARCHAR} and
     sl_custid = #{sl_custid,jdbcType=INTEGER} and companyId = #{companyid,jdbcType=INTEGER}
+    and sl_ym=#{sl_ym,jdbcType=VARCHAR}
   </select>
 
   <select id="selectByKindCodeVendid" resultType="java.lang.Long">
@@ -261,6 +262,7 @@
     from subledger
     where sl_code = #{sl_code,jdbcType=VARCHAR} and sl_kind = #{sl_kind,jdbcType=VARCHAR} and
     sl_vendid = #{sl_vendid,jdbcType=INTEGER} and companyId = #{companyid,jdbcType=INTEGER}
+    and sl_ym=#{sl_ym,jdbcType=VARCHAR}
   </select>
 
   <delete id="deleteCustomer">
@@ -274,4 +276,8 @@
     where sl_code = #{sl_code,jdbcType=VARCHAR} and sl_kind = #{sl_kind, jdbcType=VARCHAR} and
     sl_vendid = #{sl_vendid,jdbcType=INTEGER}
   </delete>
+
+  <select id="selectUnPeriod" resultType="string">
+        select PD_DETNO from periodsdetail where companyid=#{companyId} and pd_status=99 order by PD_DETNO desc LIMIT 1;
+    </select>
 </mapper>

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

@@ -208,6 +208,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
         List<Verificationdetail> items2 = verificationdetailMapper.selectByFK(id);
 
         String type = main.getVc_kind();
+        type = transferKind(type);
         if(type.equals("receipts_offset_receivable") || type.equals("prepaid_offset_payable") ||
                 type.equals("receivable_offset_payable")){
             Double total1 = new Double(0);
@@ -478,6 +479,7 @@ public class VerificationServiceImpl extends CommonBaseServiceImpl<VerificationM
             }
         }
         baseDTO.setId(id);
+        messageLogService.audit(baseDTO);
         return baseDTO;
     }