Browse Source

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

hy 7 years ago
parent
commit
9cb090e067

+ 3 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/EndProductMapper.java

@@ -26,4 +26,7 @@ public interface EndProductMapper {
     int checkPay(Long companyId);
     int checkRec(Long companyId);
     void deleteSub(Long companyId);
+    void updateSubByPeriod(@Param("ym") String ym, @Param("companyId") Long companyId);
+    void updateCustArByPeriod(@Param("ym") String ym, @Param("companyId") Long companyId);
+    void updateVendApByPeriod(@Param("ym") String ym, @Param("companyId") Long companyId);
 }

+ 12 - 3
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/EndProductServiceImpl.java

@@ -32,7 +32,6 @@ public class EndProductServiceImpl implements EndProductService {
     private MessagelogMapper messagelogMapper;
     @Autowired
     private EndProductMapper endProductMapper;
-
     @Override
     public Map<String, Object> getPeriodData(PageRequest page, ListReqDTO listReqDTO) {
         //设置分页
@@ -76,20 +75,30 @@ public class EndProductServiceImpl implements EndProductService {
     @Transactional
     @Override
     public void unEndAccount() {
-        int payc = endProductMapper.checkPay(BaseContextHolder.getCompanyId());
+        //期初被使用可以反结账不做限制
+        /*
+         int payc = endProductMapper.checkPay(BaseContextHolder.getCompanyId());
         int recc = endProductMapper.checkRec(BaseContextHolder.getCompanyId());
         if(payc !=0 || recc != 0){
             throw new BizException(500, BizExceptionCode.EARLY_USERING.getMessage());
         }
         endProductMapper.deleteSub(BaseContextHolder.getCompanyId());
-
+        */
         String period = endProductMapper.selectUnPeriod(BaseContextHolder.getCompanyId());
         if (StringUtils.isEmpty(period)){
             throw new BizException(BizExceptionCode.BIZ_UNENDPRODUCT);
         }else{
+            //将sl_ym=当前期间的期初信息更新到上一期间
+            endProductMapper.updateSubByPeriod(period,BaseContextHolder.getCompanyId());
+            //将客户、供应商期初未当前期间的更新到上一期间
+            endProductMapper.updateCustArByPeriod(period,BaseContextHolder.getCompanyId());
+            endProductMapper.updateVendApByPeriod(period,BaseContextHolder.getCompanyId());
+            //更新明细账结账状态
             endProductMapper.updateRe(period, BaseContextHolder.getCompanyId());
             endProductMapper.updatePa(period, BaseContextHolder.getCompanyId());
+            //更新期间表状态
             endProductMapper.updatePeriodStatus(0L, period, BaseContextHolder.getCompanyId());
+            //记录日志
             messageLogService.customizeLog(new DocBaseDTO(Long.valueOf(period), period, "UNENDPRODUCT"), Operation.UNENDPRODUCT);
         }
     }

+ 20 - 0
applications/commons/commons-server/src/main/resources/mapper/EndProductMapper.xml

@@ -130,4 +130,24 @@
     DELETE from subledger where sl_ym =
     (select min(pd_detno) from periodsdetail where pd_status=0 and companyid=#{companyId}) and companyid = #{companyId}
   </delete>
+    <update  id="updateSubByPeriod">
+        update subledger
+        set sl_ym=#{ym},
+        sl_date=str_to_date(CONCAT(#{ym},'01'), '%Y%m%d')
+        where companyid = #{companyId} and
+        sl_ym >=  (select min(pd_detno) from periodsdetail where pd_status=0 and companyid=#{companyId})
+        and sl_kind='期初余额'
+    </update>
+    <update  id="updateCustArByPeriod">
+        update custAramount
+        set ca_begindate=str_to_date(CONCAT(#{ym},'01'), '%Y%m%d')
+        where companyid = #{companyId} and ca_begindate is not null and
+        date_format(ca_begindate, '%Y%m' ) = (select min(pd_detno) from periodsdetail where pd_status=0 and companyid=#{companyId})
+    </update>
+    <update  id="updateVendApByPeriod">
+        update Vendapamount
+        set va_begindate=str_to_date(CONCAT(#{ym},'01'), '%Y%m%d')
+        where companyid = #{companyId} and va_begindate is not null and
+        date_format(va_begindate, '%Y%m' ) >= (select min(pd_detno) from periodsdetail where pd_status=0 and companyid=#{companyId})
+    </update>
 </mapper>

+ 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>

+ 8 - 24
frontend/saas-web/app/view/money/verification/FormPanel.js

@@ -928,52 +928,36 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 defaultConditions: {
                     receipts_offset_receivable: ['ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0 ' +
                         'and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and ((sl_kind=\'收款单\') or ' +
-                              '( sl_id =(select sl_id from subledger where ifnull(sl_custid,0)={vc_custid} and sl_kind=\'期初余额\' ' +
-                                            'and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))',
+                        ' and sl_kind in (\'收款单\',\'期初余额\')',
 
                         'ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' +
                         'and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and (sl_kind in (\'出货单\',\'销售退货单\') or '+
-                        '( sl_id =(select sl_id from subledger where ifnull(sl_custid,0)={vc_custid} and sl_kind=\'期初余额\' ' +
-                        'and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))'
+                        ' and sl_kind in (\'出货单\',\'销售退货单\',\'期初余额\')'
                     ],
                     prepaid_offset_payable: ['ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)<>0 and ifnull(sl_namount,0)<>0 ' +
                         'and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and ((sl_kind=\'付款单\') or ' +
-                        '( sl_id =(select sl_id from subledger where ifnull(sl_vendid,0)={vc_vendid} and sl_kind=\'期初余额\'' +
-                        'and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))',
+                        ' and  sl_kind in(\'付款单\',\'期初余额\')',
 
 
                         'ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' +
                         ' and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or ' +
-                        '( sl_id =(select sl_id from subledger where ifnull(sl_vendid,0)={vc_vendid} and sl_kind=\'期初余额\'' +
-                        ' and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))'
+                        ' and sl_kind in (\'采购验收单\',\'采购验退单\',\'期初余额\')'
                     ],
                     receivable_offset_payable: ['ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' +
                         ' and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and ((sl_kind in (\'出货单\',\'销售退货单\')) or ' +
-                        '( sl_id =(select sl_id from subledger where ifnull(sl_custid,0)={vc_custid} and sl_kind=\'期初余额\' ' +
-                        'and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))',
+                        ' and sl_kind in (\'出货单\',\'销售退货单\',\'期初余额\')',
 
                         'ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' +
                         ' and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or ' +
-                        '( sl_id =(select sl_id from subledger where ifnull(sl_vendid,0)={vc_vendid} and sl_kind=\'期初余额\' ' +
-                        'and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))'
+                        ' and sl_kind in (\'采购验收单\',\'采购验退单\',\'期初余额\')'
                     ],
                     receivable_to_receivable: ['ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_custid,0)={vc_custid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0 ' +
                         ' and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and ((sl_kind in (\'出货单\',\'销售退货单\')) or' +
-                        '( sl_id =(select sl_id from subledger where ifnull(sl_custid,0)={vc_custid} and sl_kind=\'期初余额\' ' +
-                        'and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))'
+                        ' and sl_kind in (\'出货单\',\'销售退货单\',\'期初余额\')'
                     ],
                     payable_to_payable: ['ifnull(sl_currency,\'RMB\') = \'{vc_currency}\' and ifnull(sl_vendid,0)={vc_vendid} and ifnull(sl_preamount,0)=0 and ifnull(sl_namount,0)<>0' +
                         ' and sl_ym<=DATE_FORMAT(str_to_date(\'{vc_date}\', \'%Y-%m-%d\'),\'%Y%m\')' +
-                        ' and (sl_kind in (\'采购验收单\',\'采购验退单\') or ' +
-                        '( sl_id =(select sl_id from subledger where ifnull(sl_vendid,0)={vc_vendid} and sl_kind=\'期初余额\' ' +
-                        ' and sl_ym>=(select min(pd_detno) from periodsdetail  where pd_status=0 and periodsdetail.companyid=subledger.companyid) order by sl_ym limit 1)))'
+                        ' and sl_kind in (\'采购验收单\',\'采购验退单\',\'期初余额\')'
                     ]
                 }
             },