ソースを参照

凯和销项发票业务

lazhaoqian 4 年 前
コミット
eb5bbf8fe5

+ 17 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/shipping/finance/InvoiceApplyFor.java

@@ -195,4 +195,21 @@ public class InvoiceApplyFor extends BaseController {
     public AjaxResult removeFeeDo(@PathVariable("fId") Long fId) {
         return tFeeDoService.removeFeeDoById(fId);
     }
+    /**
+     *   撤销开票
+     */
+    @PreAuthorize("@ss.hasPermi('financial:invoiceApplyFor:add')")
+    @Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/revoke")
+    @RepeatSubmit
+    public AjaxResult revoke(@RequestParam("tFee") String tFee,
+                             @RequestParam("tFeeDo") String tFeeDo,
+                             @RequestParam(value = "billsType",required = false) String billsType) {
+        if (StringUtils.isEmpty(billsType)){
+            billsType = "DZApplyFP";
+        }
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.revoke(tFee,tFeeDo,loginUser,billsType);
+    }
 }

+ 104 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/shipping/finance/OutputMakeOut.java

@@ -0,0 +1,104 @@
+package com.ruoyi.web.controller.shipping.finance;
+
+/**
+ * @Author ZhaoQian La
+ * @Date 2021/5/14 13:54
+ * @Version 1.0
+ */
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.annotation.RepeatSubmit;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.ServletUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.finance.domain.TFee;
+import com.ruoyi.finance.service.ITFeeDoService;
+import com.ruoyi.finance.service.ITFeeService;
+import com.ruoyi.framework.web.service.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/***
+ * 销项开票
+ */
+@RestController
+@RequestMapping("/financial/outputMakeOut")
+public class OutputMakeOut extends BaseController {
+    @Autowired
+    private ITFeeService tFeeService;
+    @Autowired
+    private ITFeeDoService tFeeDoService;
+    /**
+    * 查询销项开票数据主列表
+     */
+    @PreAuthorize("@ss.hasPermi('financial:outputMakeOut:list')")
+    //@DataScope(deptAlias = "d", userAlias = "u")
+    @GetMapping("/list")
+    public TableDataInfo list(TFee tFee) {
+        tFee.setfBilltype("INV");
+        startPage();
+        List<Map<String, Object>> list = tFeeService.selectTFeeList1(tFee);
+        return getDataTable(list);
+    }
+    /**
+     * 获取发票数据主详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('finance:outputMakeOut:query')")
+    @GetMapping(value = "/{fId}")
+    public AjaxResult getInfo(@PathVariable("fId") Long fId) {
+        return AjaxResult.success(tFeeService.selectTFeeByIdNew(fId));
+    }
+    /**
+     * 新增销项发票申请
+     *
+     * @param tFee
+     * @param tFeeDo
+     * @return
+     */
+    @PreAuthorize("@ss.hasPermi('financial:outputMakeOut:add')")
+    //@Log(title = "财务数据主", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/add")
+    @RepeatSubmit
+    public AjaxResult add(@RequestParam("tFee") String tFee,
+                          @RequestParam("tFeeDo") String tFeeDo,
+                          @RequestParam(value = "tFeeInvoice",required = false) String tFeeInvoice,
+                          @RequestParam("billsType") String billsType) {
+        if (StringUtils.isEmpty(tFee)){
+            return AjaxResult.error("财务主表信息不能为空");
+        }
+        if (StringUtils.isEmpty(tFeeDo)) {
+            return AjaxResult.error("财务明细表信息不能为空");
+        }
+        if (StringUtils.isEmpty(billsType)){
+            return AjaxResult.error("单据类型不能为空");
+        }
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return tFeeService.insertKHTFeeTFeeDo(tFee, tFeeDo, tFeeInvoice, loginUser, billsType);
+    }
+    /**
+     * 删除财务数据主
+     */
+    @PreAuthorize("@ss.hasPermi('finance:outputMakeOut:remove')")
+    @Log(title = "财务数据主", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{fIds}")
+    public AjaxResult remove(@PathVariable Long[] fIds) {
+        return toAjax(tFeeService.deleteTFeeByIds(fIds));
+    }
+
+    @PreAuthorize("@ss.hasPermi('finance:outputMakeOut:remove')")
+    @Log(title = "财务数据主", businessType = BusinessType.DELETE)
+    @DeleteMapping("/queryRemove/{fId}")
+    public AjaxResult queryRemove(@PathVariable("fId") Long fId) {
+        return tFeeService.queryRemove(fId);
+    }
+}

+ 22 - 0
ruoyi-fleet/src/main/java/com/ruoyi/orderPlan/domain/Ftmsorderbillscars.java

@@ -455,12 +455,32 @@ public class Ftmsorderbillscars extends BaseEntity {
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "收费对账日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date accchkDateDr;
+    @Excel(name = "业务利润")
+    private BigDecimal profitBill;
+    @Excel(name = "车利润")
+    private BigDecimal profitCar;
 
     /**
      *  查询日期区间
      */
     private List<String> monthList;
 
+    public BigDecimal getProfitCar() {
+        return profitCar;
+    }
+
+    public void setProfitCar(BigDecimal profitCar) {
+        this.profitCar = profitCar;
+    }
+
+    public BigDecimal getProfitBill() {
+        return profitBill;
+    }
+
+    public void setProfitBill(BigDecimal profitBill) {
+        this.profitBill = profitBill;
+    }
+
     public Long getId() {
         return id;
     }
@@ -1418,6 +1438,8 @@ public class Ftmsorderbillscars extends BaseEntity {
                 ", accchkAmtDr=" + accchkAmtDr +
                 ", accchkDateDr=" + accchkDateDr +
                 ", monthList=" + monthList +
+                ", profitBill=" + profitBill +
+                ", profitCar=" + profitCar +
                 '}';
     }
 }

+ 19 - 2
ruoyi-shipping/src/main/java/com/ruoyi/shipping/service/impl/TCtnpriceServiceImpl.java

@@ -11,7 +11,9 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.shipping.domain.TCntr;
 import com.ruoyi.shipping.domain.TCtnpriceItems;
+import com.ruoyi.shipping.mapper.TCntrMapper;
 import com.ruoyi.shipping.mapper.TCtnpriceItemsMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -34,6 +36,8 @@ public class TCtnpriceServiceImpl implements ITCtnpriceService
     private TCtnpriceMapper tCtnpriceMapper;
     @Autowired
     private TCtnpriceItemsMapper tCtnpriceItemsMapper;
+    @Autowired
+    private TCntrMapper tCntrMapper;
 
     /**
      * 查询海运运价
@@ -109,7 +113,13 @@ public class TCtnpriceServiceImpl implements ITCtnpriceService
         }
         List<TCtnprice> tCtnpriceList = tCtnpriceMapper.selectMessage(ctnprice);
         if (CollectionUtils.isNotEmpty(tCtnpriceList)){
-            return AjaxResult.error("当前起始港口的有效期内的运价条目重复,请确认");
+            for (TCtnprice Price : tCtnpriceList) {
+                if (ctnprice.getfId() != null && ctnprice.getfId() != Price.getfId()){
+                    return AjaxResult.error("当前起始港口的有效期内的运价条目重复,请确认");
+                }else if (ctnprice.getfId() == null){
+                    return AjaxResult.error("当前起始港口的有效期内的运价条目重复,请确认");
+                }
+            }
         }
         List<TCtnpriceItems> ctnpriceItems = new ArrayList<>();
         if (ctnprice.getfId() == null){
@@ -127,7 +137,8 @@ public class TCtnpriceServiceImpl implements ITCtnpriceService
                     List<TCtnpriceItems> ctnpriceItemsList = tCtnpriceItemsMapper.selectItemMeaasge(ctnprice.getfId(), ctnpriceItem.getfCntrid());
                     if (CollectionUtils.isNotEmpty(ctnpriceItemsList)){
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return AjaxResult.error("运价中集装箱编号重复,请确认");
+                        TCntr cntr = tCntrMapper.selectTCntrById(ctnpriceItem.getfCntrid());
+                        return AjaxResult.error("运价中集装箱编号"+cntr.getfNo()+"重复,请确认");
                     }
                     ctnpriceItem.setfPid(ctnprice.getfId());
                     ctnpriceItem.setCreateTime(DateUtils.getNowDate());
@@ -153,6 +164,12 @@ public class TCtnpriceServiceImpl implements ITCtnpriceService
             if (CollectionUtils.isNotEmpty(ctnpriceItems)){
                 tCtnpriceItemsMapper.deleteTCtnpriceItemsByfPid(ctnprice.getfId());
                 for (TCtnpriceItems ctnpriceItem : ctnpriceItems) {
+                    List<TCtnpriceItems> ctnpriceItemsList = tCtnpriceItemsMapper.selectItemMeaasge(ctnprice.getfId(), ctnpriceItem.getfCntrid());
+                    if (CollectionUtils.isNotEmpty(ctnpriceItemsList)){
+                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                        TCntr cntr = tCntrMapper.selectTCntrById(ctnpriceItem.getfCntrid());
+                        return AjaxResult.error("运价中集装箱编号"+cntr.getfNo()+"重复,请确认");
+                    }
                     ctnpriceItem.setfPid(ctnprice.getfId());
                     ctnpriceItem.setCreateTime(DateUtils.getNowDate());
                     ctnpriceItem.setCreateBy(SecurityUtils.getUsername());

+ 7 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/approvalFlow/service/impl/AuditPathsServiceImpl.java

@@ -501,6 +501,13 @@ public class AuditPathsServiceImpl implements IAuditPathsService {
                             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                             return ajaxResult;
                         }
+                        //生成销项发票
+                        AjaxResult invoiceFp = tFeeServiceImpl.copyInvoiceFp(auditItems.getBillId(), "INV");
+                        String string = invoiceFp.get("code").toString();
+                        if ("500".equals(string)) {
+                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                            return invoiceFp;
+                        }
                     }else if (auditItems.getActId()== 460 ){
                         if ("T".equals(at.getIffinalItem())) {
                             fettle = 6L;

+ 12 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/finance/domain/TFeeDo.java

@@ -136,6 +136,18 @@ public class TFeeDo extends BaseEntity {
     //预计开船日期
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date fBsdate;
+    /**
+     * 数据是否可修改
+     */
+    private Integer updateMessage = 1;
+
+    public Integer getUpdateMessage() {
+        return updateMessage;
+    }
+
+    public void setUpdateMessage(Integer updateMessage) {
+        this.updateMessage = updateMessage;
+    }
 
     public Date getfBsdate() {
         return fBsdate;

+ 71 - 4
ruoyi-warehouse/src/main/java/com/ruoyi/finance/service/impl/TFeeServiceImpl.java

@@ -426,6 +426,10 @@ public class TFeeServiceImpl implements ITFeeService {
     public AjaxResult insertKHTFeeTFeeDo(String tfee, String tfeeDo, String tFeeInvoice, LoginUser loginUser, String fBilltype) {
         Long fPid = null;
         Map<String, Object> map = new HashMap<>();
+        String billStatus = "2";
+        if (fBilltype.equals("INV")){
+            billStatus = "6";
+        }
         TFee tFee = JSONArray.parseObject(tfee, TFee.class);
         if (StringUtils.isNull(tFee.getfId())) {
             // 如果是新数据
@@ -437,13 +441,13 @@ public class TFeeServiceImpl implements ITFeeService {
             Date time = new Date();
             String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
             tFee.setfBillno(billNo);
-            tFee.setfBillstatus("2");
+            tFee.setfBillstatus(billStatus);
             tFeeMapper.insertTFee(tFee);
             fPid = tFee.getfId();
         } else {
             fPid = tFee.getfId();
             boolean change = this.change(fPid);
-            if (!change) {
+            if (!change && !"INV".equals(fBilltype)) {
                 return AjaxResult.error("当前数据不支持修改");
             }
             tFee.setUpdateBy(loginUser.getUser().getUserName());
@@ -461,7 +465,7 @@ public class TFeeServiceImpl implements ITFeeService {
                 tFeeDo.setfPid(fPid);
                 tFeeDo.setCreateBy(loginUser.getUser().getUserName());
                 tFeeDo.setCreateTime(new Date());
-                tFeeDo.setfStatus("2");
+                tFeeDo.setfStatus(billStatus);
                 tFeeDoMapper.insertTFeeDo(tFeeDo);
             }
         }
@@ -472,7 +476,7 @@ public class TFeeServiceImpl implements ITFeeService {
                 feeInvoice.setfPid(fPid);
                 feeInvoice.setCreateBy(loginUser.getUser().getUserName());
                 feeInvoice.setCreateTime(new Date());
-                feeInvoice.setfBillstatus("2");
+                feeInvoice.setfBillstatus(billStatus);
                 tFeeInvoiceMapper.insertTFeeInvoice(feeInvoice);
             }
         }
@@ -729,6 +733,7 @@ public class TFeeServiceImpl implements ITFeeService {
     }
 
     @Override
+    @Transactional
     public AjaxResult webVersionConfirm(Long[] fIds, String billsType, LoginUser loginUser) {
         String key = "";
         boolean isApprove = false;
@@ -827,6 +832,7 @@ public class TFeeServiceImpl implements ITFeeService {
     }
 
     @Override
+    @Transactional
     public AjaxResult confirmKaiHe(String tfee, String tfeeDo, String tFeeInvoice, LoginUser loginUser, String fBilltype) {
         Long fPid = null;
         TFee tFee = JSONArray.parseObject(tfee, TFee.class);
@@ -1047,6 +1053,12 @@ public class TFeeServiceImpl implements ITFeeService {
     public AjaxResult revoke(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
         // 更新 主表、从表
         TFee tFee = JSONArray.parseObject(tfee, TFee.class);
+        if("DZApplyFP".equals(fBilltype)){
+            TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
+            if (fee.getfMake()==1){
+                return AjaxResult.error("该申请发票已开销项发票,不能撤销");
+            }
+        }
         tFee.setUpdateBy(loginUser.getUser().getUserName());
         tFee.setUpdateTime(new Date());
         tFeeMapper.updateTFee(tFee);
@@ -1082,6 +1094,8 @@ public class TFeeServiceImpl implements ITFeeService {
             return AjaxResult.success("0");
         } else if (StringUtils.isNotNull(tFee) && StringUtils.isEmpty(tFeeDoList)) {
             return AjaxResult.success("1");
+        }else if (tFee.getfBilltype().equals("INV") && tFee.getfAccountId() !=null) {
+            return AjaxResult.success("3");
         } else {
             return AjaxResult.success("2");
         }
@@ -1532,5 +1546,58 @@ public class TFeeServiceImpl implements ITFeeService {
         return map;
     }
 
+    /**
+     * 申请发票审核成功复制数据到销项发票中
+     * @param fId  主表id
+     * @param fBilltype  类型
+     * @return
+     */
+    @Transactional
+    public AjaxResult copyInvoiceFp(Long fId,String fBilltype){
+        //查询费用主表信息复制主表信息
+        Integer insert = null;
+        TFee fee = tFeeMapper.selectTFeeById(fId);
+        TFee tFee = new TFee();
+        tFee.setfId(fee.getfId());
+        Date time = new Date();
+        String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
+        //查询费用从表信息复制主表信息
+        fee.setfAccountId(fee.getfId());
+        fee.setfBillno(billNo);
+        fee.setfBilltype(fBilltype);
+        fee.setfId(null);
+        insert = tFeeMapper.insertTFee(fee);
+        tFee.setfMake(1);
+        //修改原发票数据代表已开销项发票
+        insert = tFeeMapper.updateTFee(tFee);
+        TFeeDo tFeeDo = new TFeeDo();
+        tFeeDo.setfPid(fId);
+        List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
+        if (CollectionUtils.isNotEmpty(tFeeDoList)){
+            for (TFeeDo feeDo : tFeeDoList) {
+                feeDo.setfId(null);
+                feeDo.setfPid(fee.getfId());
+                feeDo.setfBilltype(fBilltype);
+                insert = tFeeDoMapper.insertTFeeDo(feeDo);
+            }
+        }
+        //查询开票信息复制主表信息
+        TFeeInvoice tFeeInvoice = new TFeeInvoice();
+        tFeeInvoice.setfPid(fId);
+        List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
+        if (CollectionUtils.isNotEmpty(tFeeInvoiceList)){
+            for (TFeeInvoice invoice : tFeeInvoiceList) {
+                invoice.setfId(null);
+                invoice.setfPid(fee.getfId());
+                insert = tFeeInvoiceMapper.insertTFeeInvoice(invoice);
+            }
+        }
+        if (insert != null && insert >0){
+            return AjaxResult.success();
+        }else {
+            return AjaxResult.error("生成销项发票失败,请找管理员");
+        }
+    }
+
 
 }

+ 2 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/BillnoSerialServiceImpl.java

@@ -107,6 +107,8 @@ public class BillnoSerialServiceImpl implements IBillnoSerialService {
             billNo = "ApplyFP" + billNo;
         }else if ("invoiceFP".equals(billType)) {
             billNo = "invoiceFP" + billNo;
+        }else if ("INV".equals(billType)) {
+            billNo = "INV" + billNo;
         }
         return billNo;
     }

+ 1 - 1
ruoyi-warehouse/src/main/resources/mapper/finance/TFeeMapper.xml

@@ -244,7 +244,7 @@
             <if test="fSystemType != null and fSystemType != ''">and f.f_system_type = #{fSystemType}</if>
             <if test="createBy != null and createBy != ''">and f.create_by = #{createBy}</if>
         </where>
-        ORDER BY f.create_time desc
+        ORDER BY f.f_id desc
         ${params.dataScope}
     </select>