Commit 5b5678a2 authored by zhangfeng's avatar zhangfeng

feat(wealth): 收款单,银行收款明细

parent 24d94c20
...@@ -29,4 +29,24 @@ SET approval_time = update_time ...@@ -29,4 +29,24 @@ SET approval_time = update_time
WHERE approval_time IS NULL AND `status` = 1; WHERE approval_time IS NULL AND `status` = 1;
# 刷新银行明细审核核销币种 # 刷新银行明细审核核销币种
UPDATE ecw_receipt_item SET write_off_currency_id = 1 WHERE write_off_currency_id IS NULL UPDATE ecw_receipt_item SET write_off_currency_id = 1 WHERE write_off_currency_id IS NULL;
\ No newline at end of file
UPDATE ecw_receipt SET generate_path = 0;
# 刷新应收款优惠金额
UPDATE ecw_receivable er
SET er.discount_total = 0 WHERE er.discount_total IS NULL;
# 刷新应收款汇率
UPDATE ecw_receivable er
SET er.exchange_rate = (SELECT eer.currency_rate FROM ecw_exchange_rate eer WHERE eer.source_currency_id = er.currency_id AND eer.target_currency_id = er.base_currency_id )
WHERE er.exchange_rate IS NULL AND er.receipt_id IS NOT NULL;
UPDATE ecw_receivable er
SET er.exchange_rate = 1 WHERE er.exchange_rate IS NULL AND er.receipt_id IS NOT NULL;
# 刷新应收款基准金额
UPDATE ecw_receivable er
SET er.base_amount = er.exchange_rate * (er.tax_amount - er.discount_total)
WHERE er.base_amount IS NULL AND er.receipt_id IS NOT NULL AND er.exchange_rate IS NOT NULL;
...@@ -50,4 +50,6 @@ public interface ReceivableConvert { ...@@ -50,4 +50,6 @@ public interface ReceivableConvert {
* @return * @return
*/ */
PageResult<ReceivableBackVO> convertPage(PageResult<ReceivableDO> page); PageResult<ReceivableBackVO> convertPage(PageResult<ReceivableDO> page);
List<ReceivableInItemVO> convertToItemVOList(List<ReceivableDO> receivableDOS);
} }
...@@ -104,4 +104,8 @@ public class ReceiptItemDO extends BaseDO { ...@@ -104,4 +104,8 @@ public class ReceiptItemDO extends BaseDO {
* 审核通过时间 * 审核通过时间
*/ */
private Date approvalTime; private Date approvalTime;
/**
* 备注
*/
private String remark;
} }
...@@ -19,6 +19,6 @@ public class ReceiptItemWriteOffListener { ...@@ -19,6 +19,6 @@ public class ReceiptItemWriteOffListener {
*/ */
@EventListener(ReceiptItemWriteOffEvent.class) @EventListener(ReceiptItemWriteOffEvent.class)
public void onReceiptItemWriteOff(ReceiptItemWriteOffEvent event) { public void onReceiptItemWriteOff(ReceiptItemWriteOffEvent event) {
receiptItemService.verification(event.getId()); receiptItemService.verification(event.getId(), event.getBpmResult());
} }
} }
...@@ -14,4 +14,8 @@ public class ReceiptItemWriteOffEvent { ...@@ -14,4 +14,8 @@ public class ReceiptItemWriteOffEvent {
* 主键 * 主键
*/ */
private Long id; private Long id;
/**
* 审核结果
*/
private Integer bpmResult;
} }
...@@ -226,41 +226,41 @@ public class FinanceReceiptApproveService { ...@@ -226,41 +226,41 @@ public class FinanceReceiptApproveService {
receiptMapper.updateById(updateReceipt); receiptMapper.updateById(updateReceipt);
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getKey(), bmpKey)) { } else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF.getKey(), bmpKey)) {
//收款单明细核销审核 //收款单明细核销审核
if (null == receiptApprovalDO.getReceiptItemId()) { //if (null == receiptApprovalDO.getReceiptItemId()) {
throw exception(RECEIPT_ITEM_NOT_FOUND); // throw exception(RECEIPT_ITEM_NOT_FOUND);
} //}
ReceiptItemDO receiptItemDO = receiptItemMapper.selectById(receiptApprovalDO.getReceiptItemId()); //ReceiptItemDO receiptItemDO = receiptItemMapper.selectById(receiptApprovalDO.getReceiptItemId());
if (null == receiptItemDO) { //if (null == receiptItemDO) {
throw exception(RECEIPT_ITEM_NOT_FOUND); // throw exception(RECEIPT_ITEM_NOT_FOUND);
} //}
ReceiptItemDO updateReceiptItem = new ReceiptItemDO(); //ReceiptItemDO updateReceiptItem = new ReceiptItemDO();
updateReceiptItem.setId(receiptItemDO.getId()); //updateReceiptItem.setId(receiptItemDO.getId());
updateReceiptItem.setBmpStatus(result); //updateReceiptItem.setBmpStatus(result);
if (result == BpmProcessInstanceResultEnum.APPROVE.getResult()) { //if (result == BpmProcessInstanceResultEnum.APPROVE.getResult()) {
updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF.getValue()); // updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF.getValue());
updateReceiptItem.setApprovalTime(new Date()); // updateReceiptItem.setApprovalTime(new Date());
//判断收款单状态如果是待核销状态-变成部分核销状态,其它 状态不变 // //判断收款单状态如果是待核销状态-变成部分核销状态,其它 状态不变
ReceiptDO receiptDO = receiptMapper.selectById(receiptItemDO.getReceiptId()); // ReceiptDO receiptDO = receiptMapper.selectById(receiptItemDO.getReceiptId());
if (null != receiptDO && receiptDO.getState().equals(ReceiptStatusEnum.WRITE_OFF_WAITING.getValue())) { // if (null != receiptDO && receiptDO.getState().equals(ReceiptStatusEnum.WRITE_OFF_WAITING.getValue())) {
ReceiptDO updateReceipt = new ReceiptDO(); // ReceiptDO updateReceipt = new ReceiptDO();
updateReceipt.setId(receiptDO.getId()); // updateReceipt.setId(receiptDO.getId());
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_PART_ING.getValue()); // updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_PART_ING.getValue());
receiptMapper.updateById(updateReceipt); // receiptMapper.updateById(updateReceipt);
//
//更新收该收款单下的应收为收款中状态 // //更新收该收款单下的应收为收款中状态
LambdaUpdateWrapper<ReceivableDO> lambdaUpdateWrapper = new LambdaUpdateWrapper(); // LambdaUpdateWrapper<ReceivableDO> lambdaUpdateWrapper = new LambdaUpdateWrapper();
lambdaUpdateWrapper.eq(ReceivableDO::getReceiptId, receiptDO.getId()); // lambdaUpdateWrapper.eq(ReceivableDO::getReceiptId, receiptDO.getId());
lambdaUpdateWrapper.set(ReceivableDO::getState, 1); // lambdaUpdateWrapper.set(ReceivableDO::getState, 1);
receivableService.update(lambdaUpdateWrapper); // receivableService.update(lambdaUpdateWrapper);
} // }
receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId()); // receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
} else if (result == BpmProcessInstanceResultEnum.REJECT.getResult()) { //} else if (result == BpmProcessInstanceResultEnum.REJECT.getResult()) {
updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF_APPROVE_REJECT.getValue()); // updateReceiptItem.setStatus(ReceiptItemStatusEnum.WRITE_OFF_APPROVE_REJECT.getValue());
} else if (result == BpmProcessInstanceResultEnum.CANCEL.getResult()) { //} else if (result == BpmProcessInstanceResultEnum.CANCEL.getResult()) {
updateReceiptItem.setStatus(ReceiptItemStatusEnum.DRAFT.getValue()); // updateReceiptItem.setStatus(ReceiptItemStatusEnum.DRAFT.getValue());
} //}
receiptItemMapper.updateById(updateReceiptItem); //receiptItemMapper.updateById(updateReceiptItem);
applicationContext.publishEvent(new ReceiptItemWriteOffEvent(updateReceiptItem.getId())); applicationContext.publishEvent(new ReceiptItemWriteOffEvent(receiptApprovalDO.getId(), result));
} else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF_NO.getKey(), bmpKey)) { } else if (StrUtil.equals(WorkFlowEmus.FINANCE_RECEIPT_ITEM_WRITE_OFF_NO.getKey(), bmpKey)) {
//收款单明细核销反审核 //收款单明细核销反审核
if (null == receiptApprovalDO.getReceiptItemId()) { if (null == receiptApprovalDO.getReceiptItemId()) {
......
...@@ -153,7 +153,9 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO ...@@ -153,7 +153,9 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
*/ */
private void createInvoice(ReceiptInvoiceCreateReqVO receiptInvoiceCreateReqVO, ReceiptDO receipt) { private void createInvoice(ReceiptInvoiceCreateReqVO receiptInvoiceCreateReqVO, ReceiptDO receipt) {
ReceiptInvoiceDO receiptInvoiceDO = ReceiptInvoiceConvert.INSTANCE.convertInvoiceCreateReqVO(receiptInvoiceCreateReqVO); ReceiptInvoiceDO receiptInvoiceDO = ReceiptInvoiceConvert.INSTANCE.convertInvoiceCreateReqVO(receiptInvoiceCreateReqVO);
receiptInvoiceDO.setApplyUserId(SecurityFrameworkUtils.getLoginUserId()); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
receiptInvoiceDO.setApplyUserId(loginUser.getId());
receiptInvoiceDO.setApplyUserName(loginUser.getUsername());
receiptInvoiceDO.setInvoiceHeader(receiptInvoiceCreateReqVO.getInvoice()); receiptInvoiceDO.setInvoiceHeader(receiptInvoiceCreateReqVO.getInvoice());
receiptInvoiceDO.setInvoiceAddress(receiptInvoiceCreateReqVO.getAddressPhone()); receiptInvoiceDO.setInvoiceAddress(receiptInvoiceCreateReqVO.getAddressPhone());
receiptInvoiceDO.setInvoiceItem(receiptInvoiceCreateReqVO.getProjectName()); receiptInvoiceDO.setInvoiceItem(receiptInvoiceCreateReqVO.getProjectName());
...@@ -194,10 +196,6 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO ...@@ -194,10 +196,6 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
receivableDO.setReceiptNo(receipt.getReceiptNo()); receivableDO.setReceiptNo(receipt.getReceiptNo());
receivableDO.setReceiptId(receipt.getId()); receivableDO.setReceiptId(receipt.getId());
receivableDO.setState(1); receivableDO.setState(1);
ExchangeRateRespDTO currencyRate = currencyApi.getCurrencyRate(receipt.getCurrencyId(), receivableDO.getBaseCurrencyId());
receivableDO.setExchangeRate(currencyRate.getCurrencyRate());
BigDecimal actualAmount = receivableDO.getTaxAmount().subtract(receivableDO.getDiscountTotal() == null ? BigDecimal.ZERO : receivableDO.getDiscountTotal());
receivableDO.setBaseAmount(actualAmount.multiply(currencyRate.getCurrencyRate()));
return receivableDO; return receivableDO;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
receivableService.updateBatchById(receivableDOList); receivableService.updateBatchById(receivableDOList);
...@@ -366,6 +364,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO ...@@ -366,6 +364,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
LambdaQueryWrapper<ReceivableDO> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ReceivableDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ReceivableDO::getReceiptId, updateReqVO.getId()); lambdaQueryWrapper.eq(ReceivableDO::getReceiptId, updateReqVO.getId());
List<ReceivableDO> allReceivable = receivableService.list(lambdaQueryWrapper); List<ReceivableDO> allReceivable = receivableService.list(lambdaQueryWrapper);
// TODO 校验删除的应收明细是否已收款
for (ReceivableDO receivableDO : allReceivable) { for (ReceivableDO receivableDO : allReceivable) {
if (receivableUpdateReqVOList.stream().noneMatch(w -> Objects.equals(w.getId(), receivableDO.getId()))) { if (receivableUpdateReqVOList.stream().noneMatch(w -> Objects.equals(w.getId(), receivableDO.getId()))) {
LambdaUpdateWrapper<ReceivableDO> update = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<ReceivableDO> update = new LambdaUpdateWrapper<>();
...@@ -1027,6 +1026,9 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO ...@@ -1027,6 +1026,9 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
if (receiptDO.getInvoiceId() != null) { if (receiptDO.getInvoiceId() != null) {
ReceiptInvoiceDO receiptInvoiceDO = receiptInvoiceMapper.selectById(receiptDO.getInvoiceId()); ReceiptInvoiceDO receiptInvoiceDO = receiptInvoiceMapper.selectById(receiptDO.getInvoiceId());
InvoiceInReceiptRespVO invoiceInReceiptRespVO = ReceiptInvoiceConvert.INSTANCE.convertRespVO(receiptInvoiceDO); InvoiceInReceiptRespVO invoiceInReceiptRespVO = ReceiptInvoiceConvert.INSTANCE.convertRespVO(receiptInvoiceDO);
if (receiptInvoiceDO.getInvoicerId() != null) {
invoiceInReceiptRespVO.setInvoicerName(adminUserApi.getUserName(receiptInvoiceDO.getInvoicerId().toString()));
}
invoiceInReceiptRespVO.setInvoice(receiptInvoiceDO.getInvoiceHeader()); invoiceInReceiptRespVO.setInvoice(receiptInvoiceDO.getInvoiceHeader());
invoiceInReceiptRespVO.setAddressPhone(receiptInvoiceDO.getInvoiceAddress()); invoiceInReceiptRespVO.setAddressPhone(receiptInvoiceDO.getInvoiceAddress());
invoiceInReceiptRespVO.setProjectName(receiptInvoiceDO.getInvoiceItem()); invoiceInReceiptRespVO.setProjectName(receiptInvoiceDO.getInvoiceItem());
......
...@@ -273,7 +273,7 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap ...@@ -273,7 +273,7 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptDO.setInvoicingStatus(CANCELLED.getValue()); receiptDO.setInvoicingStatus(CANCELLED.getValue());
receiptMapper.updateById(receiptDO); receiptMapper.updateById(receiptDO);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
receiptInvoiceDO.setApplyUserId(loginUser.getId()); receiptInvoiceDO.setCancelUserId(loginUser.getId());
receiptInvoiceDO.setCancelTime(new Date()); receiptInvoiceDO.setCancelTime(new Date());
receiptInvoiceMapper.updateById(receiptInvoiceDO); receiptInvoiceMapper.updateById(receiptInvoiceDO);
recordLog(receiptInvoiceDO.getId(), InvoicingLinkEnum.CANCEL_INVOICE, reqVO.getRemark(), null); recordLog(receiptInvoiceDO.getId(), InvoicingLinkEnum.CANCEL_INVOICE, reqVO.getRemark(), null);
......
...@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo; ...@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo; import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchCreateReqVO; import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchRespVO; import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemBackVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO; import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO; import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO;
...@@ -62,11 +63,11 @@ public interface ReceiptItemService extends IService<ReceiptItemDO> { ...@@ -62,11 +63,11 @@ public interface ReceiptItemService extends IService<ReceiptItemDO> {
/** /**
* 核销 * 处理审批结果
* *
* @param id * @param id
*/ */
void verification(Long id); void verification(Long id,Integer bpmResult);
/** /**
* 批量核销 * 批量核销
...@@ -123,4 +124,6 @@ public interface ReceiptItemService extends IService<ReceiptItemDO> { ...@@ -123,4 +124,6 @@ public interface ReceiptItemService extends IService<ReceiptItemDO> {
BigDecimal getWriteOffAmountByReceiptId( Long receiptId); BigDecimal getWriteOffAmountByReceiptId( Long receiptId);
List<ReceiptItemBatchRespVO> receiptItemImport(List<ReceiptItemBatchCreateReqVO> list, Boolean ignoreItem); List<ReceiptItemBatchRespVO> receiptItemImport(List<ReceiptItemBatchCreateReqVO> list, Boolean ignoreItem);
ReceiptItemBackVO getReceiptItemDetail(Long id);
} }
...@@ -16,10 +16,13 @@ import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO; ...@@ -16,10 +16,13 @@ import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.ecw.api.currency.dto.ExchangeRateRespDTO; import cn.iocoder.yudao.module.ecw.api.currency.dto.ExchangeRateRespDTO;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.wealth.convert.receiptItem.ReceiptItemConvert; import cn.iocoder.yudao.module.wealth.convert.receiptItem.ReceiptItemConvert;
import cn.iocoder.yudao.module.wealth.convert.receivable.ReceivableConvert;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO; import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptApproval.ReceiptApprovalDO; import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptApproval.ReceiptApprovalDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO; import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableWriteOffRecord;
import cn.iocoder.yudao.module.wealth.dal.mysql.receipt.ReceiptMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.ReceiptItemMapper; import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.ReceiptItemMapper;
import cn.iocoder.yudao.module.wealth.enums.ReceiptItemStatusEnum; import cn.iocoder.yudao.module.wealth.enums.ReceiptItemStatusEnum;
import cn.iocoder.yudao.module.wealth.enums.ReceiptLinkEnum; import cn.iocoder.yudao.module.wealth.enums.ReceiptLinkEnum;
...@@ -32,8 +35,10 @@ import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo; ...@@ -32,8 +35,10 @@ import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo; import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchCreateReqVO; import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchRespVO; import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptItemBatchRespVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemBackVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO; import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO; import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableInItemVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableWriteOffReqVO; import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableWriteOffReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
...@@ -71,6 +76,8 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R ...@@ -71,6 +76,8 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
@Resource @Resource
private ReceiptService receiptService; private ReceiptService receiptService;
@Resource @Resource
private ReceiptMapper receiptMapper;
@Resource
private ReceivableService receivableService; private ReceivableService receivableService;
@Resource @Resource
private DictDataApi dictDataApi; private DictDataApi dictDataApi;
...@@ -199,58 +206,57 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R ...@@ -199,58 +206,57 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void verification(Long id) { public void verification(Long id, Integer bpmResult) {
ReceiptItemDO receiptItemDO = this.getReceiptItem(id); //收款单明细核销审核
if (receiptItemDO == null) { if (null == id) {
throw exception(RECEIPTITEM_NOT_EXISTS); throw exception(RECEIPT_ITEM_NOT_FOUND);
}
ReceiptItemDO receiptItemDO = receiptItemMapper.selectById(id);
if (null == receiptItemDO) {
throw exception(RECEIPT_ITEM_NOT_FOUND);
} }
if (receiptItemDO.getStatus() != 0) { if (receiptItemDO.getStatus() != 0) {
throw exception(RECEIPTITEM_VERIFICATION); throw exception(RECEIPTITEM_VERIFICATION);
} }
receiptItemDO.setBmpStatus(bpmResult);
// 核销通过
if (Objects.equals(bpmResult, BpmProcessInstanceResultEnum.APPROVE.getResult())) {
receiptItemDO.setStatus(ReceiptItemStatusEnum.WRITE_OFF.getValue());
receiptItemDO.setApprovalTime(new Date());
ReceiptItemDO updateReceiptItemDO = new ReceiptItemDO(); // 更新收款单
updateReceiptItemDO.setId(receiptItemDO.getId()); ReceiptDO receiptDO = receiptMapper.selectById(receiptItemDO.getReceiptId());
updateReceiptItemDO.setStatus(1); //判断收款单状态如果是待核销状态-变成部分核销状态,其它 状态不变
this.updateById(updateReceiptItemDO); if (null != receiptDO && receiptDO.getState().equals(ReceiptStatusEnum.WRITE_OFF_WAITING.getValue())) {
receiptDO.setState(ReceiptStatusEnum.WRITE_OFF_PART_ING.getValue());
if (null == receiptItemDO.getReceiptId()) {
throw exception(RECEIPT_NOT_EXISTS);
} }
// TODO 是否更新核销金额,核销比例
ReceiptDO receiptDO = receiptService.getById(receiptItemDO.getReceiptId()); BigDecimal writeOffAmount = receiptItemMapper.getWriteOffAmountByReceiptId(receiptDO.getId());
if (null == receiptDO) { if (null != receiptDO.getReceivableTotalAmount() && receiptDO.getReceivableTotalAmount().compareTo(BigDecimal.ZERO) == 1) {
throw exception(RECEIPT_NOT_EXISTS); receiptDO.setWriteOffProportion(writeOffAmount.divide(receiptDO.getReceivableTotalAmount(), 8, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP));
} }
receiptService.updateById(receiptDO);
if (receiptDO.getState() == 0) { //更新应收明细
throw exception(RECEIPT_STATUS_NOT_WRITE_OFF); List<ReceivableDO> receivableDOS = receivableService.selectList("receipt_id", receiptItemDO.getReceiptId());
for (ReceivableDO receivableDO : receivableDOS) {
receivableDO.setState(1);
ReceivableWriteOffRecord receivableWriteOffRecord = receivableService.getReceivableWriteOffRecord(receivableDO.getId(), receiptItemDO.getId());
if (null != receivableWriteOffRecord) {
receivableDO.setWriteOffAmount(receivableDO.getWriteOffAmount().add(receivableWriteOffRecord.getWriteOffAmount()));
} }
//设置应收明细为收款中
LambdaUpdateWrapper<ReceivableDO> lambdaReceivableUpdateWrapper = new LambdaUpdateWrapper();
lambdaReceivableUpdateWrapper.set(ReceivableDO::getState, 1);
lambdaReceivableUpdateWrapper.eq(ReceivableDO::getReceiptId, receiptDO.getId());
lambdaReceivableUpdateWrapper.eq(ReceivableDO::getState, 0);
receivableService.update(lambdaReceivableUpdateWrapper);
//需要计算出核销比例
BigDecimal writeOffAmount = receiptItemMapper.getWriteOffAmountByReceiptId(receiptDO.getId());
ReceiptDO updateReceiptDO = new ReceiptDO();
updateReceiptDO.setId(receiptDO.getId());
//需要计算出核销比例
if (receiptDO.getState() == 2) {
updateReceiptDO.setState(3);
} }
receivableService.updateBatchById(receivableDOS);
if (null != receiptDO.getReceivableTotalAmount() && receiptDO.getReceivableTotalAmount().compareTo(BigDecimal.ZERO) == 1) { receiptService.updateReceiptItemStatus(receiptItemDO.getReceiptId());
updateReceiptDO.setWriteOffProportion(writeOffAmount.divide(receiptDO.getReceivableTotalAmount(), 8, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(6, BigDecimal.ROUND_HALF_UP));
} }
// 审核拒绝
receiptService.updateById(updateReceiptDO); else if (Objects.equals(bpmResult, BpmProcessInstanceResultEnum.REJECT.getResult())) {
receiptItemDO.setStatus(ReceiptItemStatusEnum.WRITE_OFF_APPROVE_REJECT.getValue());
}
// 取消审核
else if (Objects.equals(bpmResult, BpmProcessInstanceResultEnum.CANCEL.getResult())) {
receiptItemDO.setStatus(ReceiptItemStatusEnum.DRAFT.getValue());
}
receiptItemMapper.updateById(receiptItemDO);
} }
@Override @Override
...@@ -590,6 +596,26 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R ...@@ -590,6 +596,26 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
return respVOS; return respVOS;
} }
@Override
public ReceiptItemBackVO getReceiptItemDetail(Long id) {
ReceiptItemDO receiptItemDO = receiptItemMapper.selectById(id);
if (null == receiptItemDO) {
throw exception(RECEIPT_ITEM_NOT_FOUND);
}
ReceiptItemBackVO itemBackVO = ReceiptItemConvert.INSTANCE.convert(receiptItemDO);
List<ReceivableDO> receivableDOS = receivableService.selectList("receipt_id", itemBackVO.getReceiptId());
List<ReceivableInItemVO> receivableInItemVOS = ReceivableConvert.INSTANCE.convertToItemVOList(receivableDOS);
for (ReceivableInItemVO receivableInItemVO : receivableInItemVOS) {
ReceivableWriteOffRecord receivableWriteOffRecord = receivableService.getReceivableWriteOffRecord(receivableInItemVO.getId(), id);
if (null == receivableWriteOffRecord) {
receivableInItemVO.setWriteOffInCurrentItem(BigDecimal.ZERO);
}
receivableInItemVO.setWriteOffInCurrentItem(receivableWriteOffRecord.getWriteOffAmount());
}
itemBackVO.setReceivableList(receivableInItemVOS);
return itemBackVO;
}
private ReceiptItemBatchRespVO validateBatchReceiptItem(ReceiptItemBatchCreateReqVO batchCreateReqVO, Boolean ignoreItem, ArrayList<ReceiptItemCreateReqVO> receiptItemCreateReqVOS) { private ReceiptItemBatchRespVO validateBatchReceiptItem(ReceiptItemBatchCreateReqVO batchCreateReqVO, Boolean ignoreItem, ArrayList<ReceiptItemCreateReqVO> receiptItemCreateReqVOS) {
// 校验单个字段合法性 // 校验单个字段合法性
ReceiptItemBatchRespVO commonFieldRes = validateBatchReceiptItemCommonField(batchCreateReqVO); ReceiptItemBatchRespVO commonFieldRes = validateBatchReceiptItemCommonField(batchCreateReqVO);
......
...@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.service.IService; ...@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO; import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO; import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receivable.ReceivableWriteOffRecord;
import cn.iocoder.yudao.module.wealth.vo.receivable.*; import cn.iocoder.yudao.module.wealth.vo.receivable.*;
import javax.validation.Valid; import javax.validation.Valid;
...@@ -271,4 +272,6 @@ public interface ReceivableService extends IService<ReceivableDO> { ...@@ -271,4 +272,6 @@ public interface ReceivableService extends IService<ReceivableDO> {
Long getDestCountryCurrencyId(Long orderId); Long getDestCountryCurrencyId(Long orderId);
void createWriteOffRecord(ReceivableWriteOffReqVO receivableWriteOffReqVO, ReceiptItemDO receiptItem); void createWriteOffRecord(ReceivableWriteOffReqVO receivableWriteOffReqVO, ReceiptItemDO receiptItem);
ReceivableWriteOffRecord getReceivableWriteOffRecord(Long receivableId, Long receiptItemId);
} }
...@@ -313,10 +313,16 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -313,10 +313,16 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
receivableBackVO.setWriteOffAmount(BigDecimal.ZERO); receivableBackVO.setWriteOffAmount(BigDecimal.ZERO);
} }
receivableBackVO.setNotWriteOffAmount(receivableBackVO.getActualAmount().subtract(receivableBackVO.getWriteOffAmount())); receivableBackVO.setNotWriteOffAmount(receivableBackVO.getActualAmount().subtract(receivableBackVO.getWriteOffAmount()));
// TODO 核销/未核销美元暂时默认为0,待计算 if (receivableBackVO.getExchangeRate() != null) {
receivableBackVO.setWriteOffAmountUsd(receivableBackVO.getWriteOffAmount().multiply(receivableBackVO.getExchangeRate()));
receivableBackVO.setNotWriteOffAmountUsd(receivableBackVO.getNotWriteOffAmount().multiply(receivableBackVO.getExchangeRate()));
} else {
receivableBackVO.setWriteOffAmountUsd(BigDecimal.ZERO); receivableBackVO.setWriteOffAmountUsd(BigDecimal.ZERO);
receivableBackVO.setNotWriteOffAmountUsd(BigDecimal.ZERO); receivableBackVO.setNotWriteOffAmountUsd(BigDecimal.ZERO);
}
if (receivableBackVO.getBaseAmount() == null) {
receivableBackVO.setBaseAmount(BigDecimal.ZERO); receivableBackVO.setBaseAmount(BigDecimal.ZERO);
}
// 核销比例 = 已核销金额 / 实际金额,保留两位小数字符串 // 核销比例 = 已核销金额 / 实际金额,保留两位小数字符串
receivableBackVO.setWriteOffProportion(receivableBackVO.getWriteOffAmount().divide(receivableBackVO.getActualAmount(), 2, RoundingMode.HALF_UP).toString()); receivableBackVO.setWriteOffProportion(receivableBackVO.getWriteOffAmount().divide(receivableBackVO.getActualAmount(), 2, RoundingMode.HALF_UP).toString());
}); });
...@@ -584,4 +590,9 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec ...@@ -584,4 +590,9 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
.build(); .build();
receivableWriteOffRecordMapper.insert(writeOffRecord); receivableWriteOffRecordMapper.insert(writeOffRecord);
} }
@Override
public ReceivableWriteOffRecord getReceivableWriteOffRecord(Long receivableId, Long receiptItemId) {
return receivableWriteOffRecordMapper.selectOne("receivable_id", receivableId, "receipt_item_id", receiptItemId);
}
} }
\ No newline at end of file
package cn.iocoder.yudao.module.wealth.vo.receipt; package cn.iocoder.yudao.module.wealth.vo.receipt;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
...@@ -8,6 +9,8 @@ import lombok.NoArgsConstructor; ...@@ -8,6 +9,8 @@ import lombok.NoArgsConstructor;
import java.util.Date; import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data @Data
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
...@@ -33,6 +36,7 @@ public class ReceiptLogBackVO { ...@@ -33,6 +36,7 @@ public class ReceiptLogBackVO {
private String bpmStatus; private String bpmStatus;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date createTime; private Date createTime;
} }
...@@ -23,6 +23,12 @@ public class InvoiceInReceiptRespVO { ...@@ -23,6 +23,12 @@ public class InvoiceInReceiptRespVO {
@ApiModelProperty(value = "纳税人识别号") @ApiModelProperty(value = "纳税人识别号")
private String taxpayer; private String taxpayer;
@ApiModelProperty(value = "开户行")
private String accountBank;
@ApiModelProperty(value = "开户账号")
private String accountName;
@ApiModelProperty(value = "税率") @ApiModelProperty(value = "税率")
private java.math.BigDecimal taxRate; private java.math.BigDecimal taxRate;
...@@ -50,6 +56,9 @@ public class InvoiceInReceiptRespVO { ...@@ -50,6 +56,9 @@ public class InvoiceInReceiptRespVO {
@ApiModelProperty(value = "开发票人id") @ApiModelProperty(value = "开发票人id")
private Long invoicerId; private Long invoicerId;
@ApiModelProperty(value = "开发票人")
private String invoicerName;
@ApiModelProperty(value = "开票时间") @ApiModelProperty(value = "开票时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date invoiceTime; private Date invoiceTime;
......
package cn.iocoder.yudao.module.wealth.vo.receiptItem; package cn.iocoder.yudao.module.wealth.vo.receiptItem;
import com.fasterxml.jackson.annotation.JsonFormat; import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableInItemVO;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import org.springframework.format.annotation.DateTimeFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
...@@ -123,4 +126,10 @@ public class ReceiptItemBackVO { ...@@ -123,4 +126,10 @@ public class ReceiptItemBackVO {
@ApiModelProperty(value = "审核通过时间") @ApiModelProperty(value = "审核通过时间")
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date approvalTime; private Date approvalTime;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "收款明细列表")
private List<ReceivableInItemVO> receivableList;
} }
...@@ -67,4 +67,6 @@ public class ReceiptItemBaseVO { ...@@ -67,4 +67,6 @@ public class ReceiptItemBaseVO {
@ApiModelProperty(value = "核销金额") @ApiModelProperty(value = "核销金额")
private java.math.BigDecimal writeOffAmount; private java.math.BigDecimal writeOffAmount;
@ApiModelProperty(value = "备注")
private String remark;
} }
package cn.iocoder.yudao.module.wealth.vo.receivable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 银行收款明细中的应收明细 Response VO
*/
@Data
@ApiModel("管理后台 - 银行收款明细中的应收明细 Response VO")
public class ReceivableInItemVO {
@ApiModelProperty(value = "主键", required = true)
private Long id;
@ApiModelProperty(value = "收款单id")
private Long receiptId;
@ApiModelProperty(value = "费用类型(字典 receivable_fee_type)")
private Integer feeType;
@ApiModelProperty(value = "汇率")
private BigDecimal exchangeRate;
@ApiModelProperty(value = "货币id")
private Long currencyId;
@ApiModelProperty(value = "总金额")
private BigDecimal totalAmount;
@ApiModelProperty(value = "收款状态(0未收款,1收款中,2已收款)")
private Integer state;
@ApiModelProperty(value = "费用来源:1 订单计算 2 费用申请 3 特需费用")
private Integer feeSource;
@ApiModelProperty(value = "未核销金额")
private BigDecimal notWriteOffAmount;
@ApiModelProperty(value = "核销比例")
private String writeOffProportion;
@ApiModelProperty(value = "基准金额")
private BigDecimal baseAmount;
@ApiModelProperty(value = "实际金额")
private BigDecimal actualAmount;
@ApiModelProperty(value = "核销金额")
private BigDecimal writeOffAmountUsd;
@ApiModelProperty(value = "未核销金额")
private BigDecimal notWriteOffAmountUsd;
@ApiModelProperty(value = "基准币种id")
private Long baseCurrencyId;
@ApiModelProperty(value = "本次核销金额")
private BigDecimal writeOffInCurrentItem;
}
...@@ -95,15 +95,11 @@ public class ReceiptItemController { ...@@ -95,15 +95,11 @@ public class ReceiptItemController {
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得收款明细详情") @ApiOperation("获得收款明细详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<ReceiptItemBackVO> getReceiptItem(@RequestParam("id") Long id) { public CommonResult<ReceiptItemBackVO> getReceiptItemDetail(@RequestParam("id") Long id) {
ReceiptItemDO receiptItem = receiptItemService.getReceiptItem(id); ReceiptItemBackVO receiptItemVO = receiptItemService.getReceiptItemDetail(id);
ReceiptItemBackVO v = ReceiptItemConvert.INSTANCE.convert(receiptItem); getSY(receiptItemVO, receiptItemVO.getReceiptId());
//计算剩余金额 SetData(receiptItemVO);
//BigDecimal p = receiptItemService.getWriteOffAmountByReceiptId(id); return success(receiptItemVO);
//BigDecimal t = receiptAccountMapper.getWriteOffAmountByReceiptId(id);
getSY(v, v.getReceiptId());
SetData(v);
return success(v);
} }
private void SetData(ReceiptItemBackVO v) { private void SetData(ReceiptItemBackVO v) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment