Kaynağa Gözat

财务开票申请作废

wucl 11 ay önce
ebeveyn
işleme
6d19505cca

+ 15 - 4
biz-base/src/main/java/com/dayou/controller/FinanceInvoiceController.java

@@ -64,7 +64,7 @@ public class FinanceInvoiceController extends BaseController {
     }
 
     /**
-     * 开票审批
+     * 开票
      * @param financeInvoice
      * @return
      */
@@ -95,13 +95,24 @@ public class FinanceInvoiceController extends BaseController {
     }
 
     /**
+     * 开票作废申请
+     * @param financeInvoice
+     * @return
+     */
+    @PutMapping("/cancellation")
+    public RestResponse<Boolean> cancellation(@RequestBody FinanceInvoice financeInvoice){
+        Boolean ret = financeInvoiceService.cancellation(financeInvoice);
+        return RestResponse.data(ret);
+    }
+
+    /**
      * 开票作废
      * @param id
      * @return
      */
-    @GetMapping("/cancellation/{id}")
-    public RestResponse<Boolean> cancellation(@PathVariable("id") Long id){
-        Boolean ret = financeInvoiceService.cancellation(id);
+    @GetMapping("/cancelling/{id}")
+    public RestResponse<Boolean> cancelling(@PathVariable("id") Long id){
+        Boolean ret = financeInvoiceService.cancelling(id);
         return RestResponse.data(ret);
     }
 

+ 7 - 1
dao/src/main/resources/mapper/FinanceInvoiceMapper.xml

@@ -45,7 +45,7 @@
     <select id="getPage" parameterType="com.dayou.entity.FinanceInvoice" resultType="com.dayou.vo.FinanceInvoiceVo">
         SELECT
             fi.*,
-            orf.business_type,
+            (case orf.business_type when 'ASSET_BUSINESS' THEN '资产业务' WHEN 'MAJOR_BUSINESS' THEN '大中型业务' else '个贷业务' end) as businessType,
             orf.order_id,
             orf.order_name,
             (orf.should_amount=orf.real_amount) as isPayAll,
@@ -55,6 +55,12 @@
                 LEFT JOIN order_fund orf ON fi.order_fund_id = orf.id
                 LEFT JOIN user u ON u.id = fi.apply_id
         where fi.deleted = 0 and orf.deleted = 0
+          <if test="vo!=null and vo.state!=null and vo.state!='' and vo.state=='审核中' ">
+              and (fi.state = '申请作废' or fi.state = '审核中')
+          </if>
+        <if test="vo!=null and vo.state!=null and vo.state!='' and vo.state!='审核中' ">
+            and fi.state = #{vo.state}
+        </if>
         <if test="keyword!=null and keyword!='' ">
             and (
             fi.title like concat ('%',#{keyword},'%')

+ 2 - 1
domain/src/main/java/com/dayou/enums/FinanceInvoiceState.java

@@ -10,7 +10,8 @@ package com.dayou.enums;
 public enum FinanceInvoiceState {
     审核中,
     驳回,
-    作废,
+    申请作废,
+    已作废,
     待开票,
     已开票,
     撤销,

+ 3 - 1
service/src/main/java/com/dayou/service/IFinanceInvoiceService.java

@@ -34,7 +34,9 @@ public interface IFinanceInvoiceService extends IService<FinanceInvoice> {
 
     List<FinanceInvoice> getList(Long id, Long productionFundId);
 
-        Boolean cancellation(Long id);
+        Boolean cancellation(FinanceInvoice financeInvoice);
 
     List<FinanceInvoiceVo> getInvoiceAmountInfo(MajorProductionSimpleDTO simpleDTO);
+
+    Boolean cancelling(Long id);
 }

+ 18 - 5
service/src/main/java/com/dayou/service/impl/FinanceInvoiceServiceImpl.java

@@ -110,13 +110,15 @@ public class FinanceInvoiceServiceImpl extends ServiceImpl<FinanceInvoiceMapper,
     }
 
     @Override
-    public Boolean cancellation(Long id) {
+    public Boolean cancellation(FinanceInvoice financeInvoice) {
+        Long id = financeInvoice.getId();
         FinanceInvoice invoice = this.getById(id);
-        if (invoice.getState().equals(FinanceInvoiceState.已开票.name())){
-            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"此开票申请已开票,无法作废。请联系财务同事确认。");
+        if (!invoice.getState().equals(FinanceInvoiceState.已开票.name())){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"此发票还未开具,无法申请作废。");
         }
-
-        return this.update(new LambdaUpdateWrapper<FinanceInvoice>().set(FinanceInvoice::getState, FinanceInvoiceState.作废).eq(BaseEntity::getId,id));
+        return this.update(new LambdaUpdateWrapper<FinanceInvoice>().set(FinanceInvoice::getState, FinanceInvoiceState.申请作废)
+                        .set(FinanceInvoice::getReason,financeInvoice.getReason())
+                .eq(BaseEntity::getId,id));
     }
 
     @Override
@@ -130,4 +132,15 @@ public class FinanceInvoiceServiceImpl extends ServiceImpl<FinanceInvoiceMapper,
         }
         return financeInvoiceMapper.getInvoiceAmountInfo(simpleDTO);
     }
+
+    @Override
+    public Boolean cancelling(Long id) {
+        FinanceInvoice invoice = this.getById(id);
+        if (!invoice.getState().equals(FinanceInvoiceState.申请作废.name())){
+            ErrorCode.throwBusinessException(ErrorCode.CUSTOM_ERROR,"发票状态错误,无法作废。");
+        }
+
+        return this.update(new LambdaUpdateWrapper<FinanceInvoice>().set(FinanceInvoice::getState, FinanceInvoiceState.已作废).eq(BaseEntity::getId,id));
+
+    }
 }