Commit f857a43a authored by zhangfeng's avatar zhangfeng

feat(wealth): 优化

parent 61f8bdf2
This diff is collapsed.
......@@ -50,3 +50,5 @@ 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;
# 修改收款单已核销待开票状态
UPDATE `ecw_receipt` SET `state` = 4 WHERE `state` = 5;
\ No newline at end of file
......@@ -54,4 +54,9 @@ INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('开票申请/修改', '', 2, 1, 1624, 'invoiceOperate', 'bug', 'ecw/financial/invoiceOperate', 0, '1', '2024-12-23 11:17:32', '1', '2024-12-23 11:17:32', b'0', b'0', 'invoice application/amendment', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('开票管理', '', 2, 2, 1624, 'invoiceManagement', 'order', 'ecw/financial/invoiceManagement', 0, '1', '2024-12-24 18:13:46', '1', '2024-12-24 18:13:46', b'0', b'1', 'invoiceManagement', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('收款数据审批列表', '', 2, 2, 1624, 'collectionApprovalList', 'clipboard', 'ecw/financial/collectionApprovalList', 0, '1', '2025-01-03 08:58:08', '1', '2025-01-03 08:58:08', b'0', b'1', 'collectionApprovalList', b'0', NULL, NULL);
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('审批', 'ecw:collectionApprovalList:update', 3, 1, 2388, '', '', '', 0, '1', '2025-01-03 16:59:36', '1', '2025-01-03 16:59:36', b'0', b'1', 'approve', b'0', NULL, NULL);
\ No newline at end of file
INSERT INTO `system_menu` (`name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `is_show_in_menu_bar`, `name_en`, `keepalive`, `redirect`, `badge_field`) VALUES ('审批', 'ecw:collectionApprovalList:update', 3, 1, 2388, '', '', '', 0, '1', '2025-01-03 16:59:36', '1', '2025-01-03 16:59:36', b'0', b'1', 'approve', b'0', NULL, NULL);
UPDATE `system_menu` SET `name` = '银行账户', `permission` = '', `menu_type` = 2, `sort` = 9, `parent_id` = 1624, `path` = 'bank-account', `icon` = 'lock', `component` = 'ecw/bankAccount/index', `status` = 0, `creator` = '', `create_time` = '2022-05-09 11:40:51', `updater` = '1', `update_time` = '2024-12-20 13:36:45', `deleted` = b'0', `is_show_in_menu_bar` = b'1', `name_en` = 'Bank account management', `keepalive` = b'0', `redirect` = NULL, `badge_field` = NULL WHERE `id` = 1269;
UPDATE `system_dict_data` SET `status` = 1 WHERE `id` = 1784;
UPDATE `system_dict_data` SET `label` = '审批拒绝' WHERE `id` = 2096;
\ No newline at end of file
......@@ -15,10 +15,10 @@ public enum ReceiptStatusEnum implements IntArrayValuable {
WRITE_OFF_WAITING(2, "待提交", "write_off_waiting"),
WRITE_OFF_PART_ING(3, "已部分核销", "write_off_part_ing"),
WRITE_OFF_ALL_SUCCESS(4, "已核销", "WRITE_OFF_ALL_SUCCESS"),
WRITE_OFF_ALL_OPENING(5, "已核销,待开票", "WRITE_OFF_ALL_OPENING"),
//WRITE_OFF_ALL_OPENING(5, "已核销,待开票", "WRITE_OFF_ALL_OPENING"),
OPEN_BILL(6, "已开票", "OPEN_BILL"),
APPROVE_ING(7, "审核中", "APPROVE_ING"),
APPROVE_FAIL(8, "审核失败", "APPROVE_FAIL"),
APPROVE_FAIL(8, "审批拒绝", "APPROVE_FAIL"),
APPROVE_NEGATION(9, "反审核中", "APPROVE_NEGATION"),
WRITE_OFF_ALL_ING(10, "全部核销中", "WRITE_OFF_ALL_ING"),
WRITE_OFF_ALL_NEGATION(11, "反核销审核中", "WRITE_OFF_ALL_NEGATION"),
......
......@@ -136,13 +136,7 @@ public class FinanceReceiptApproveService {
updateReceipt.setId(receiptDO.getId());
updateReceipt.setBmpStatus(result);
if (result == BpmProcessInstanceResultEnum.APPROVE.getResult()) {
//需要根据是否要开票变成已核销,还是已核销待开票
if (receiptDO.getOpenInvoice() == 0) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
}
if (receiptDO.getOpenInvoice() == 1) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_OPENING.getValue());
}
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
//更新收该收款单下的应收为收款完成状态
LambdaUpdateWrapper<ReceivableDO> lambdaUpdateWrapper = new LambdaUpdateWrapper();
......@@ -207,21 +201,10 @@ public class FinanceReceiptApproveService {
List orderIds = orderList.stream().map(ReceivableDO::getOrderId).distinct().collect(Collectors.toList());
receivableService.orderReceivableCancelWriteOffLogAdd(orderIds, receiptDO.getReceiptNo());
} else if (result == BpmProcessInstanceResultEnum.REJECT.getResult()) {
//需要根据是否要开票变成已核销,还是已核销待开票
if (receiptDO.getOpenInvoice() == 0) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
}
if (receiptDO.getOpenInvoice() == 1) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_OPENING.getValue());
}
//已核销待开票状态已取消
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
} else if (result == BpmProcessInstanceResultEnum.CANCEL.getResult()) {
//需要根据是否要开票变成已核销,还是已核销待开票
if (receiptDO.getOpenInvoice() == 0) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
}
if (receiptDO.getOpenInvoice() == 1) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_OPENING.getValue());
}
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
}
updateReceipt.setComment(comment);
receiptMapper.updateById(updateReceipt);
......
......@@ -1027,13 +1027,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
// updateReceipt.setOrderId(receiptDO.getOrderId());
updateReceipt.setId(receiptDO.getId());
//需要根据是否要开票变成已核销,还是已核销待开票
if (receiptDO.getOpenInvoice() == 0) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
}
if (receiptDO.getOpenInvoice() == 1) {
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_OPENING.getValue());
}
updateReceipt.setState(ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue());
updateReceipt.setWriteOffAt(new Date());
updateReceipt.setWriteOffProportion(new BigDecimal("100"));//设置核销比例
......@@ -1103,16 +1097,18 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
List<ReceiptLogBackVO> receiptLogVOS = ReceiptConvert.INSTANCE.convertLogList(receiptLogDOS);
backVO.setLogList(receiptLogVOS);
}
if (receiptDO.getInvoiceId() != null) {
if (receiptDO.getOpenInvoice() != null && receiptDO.getOpenInvoice() == 1 && receiptDO.getInvoiceId() != null) {
ReceiptInvoiceDO receiptInvoiceDO = receiptInvoiceMapper.selectById(receiptDO.getInvoiceId());
InvoiceInReceiptRespVO invoiceInReceiptRespVO = ReceiptInvoiceConvert.INSTANCE.convertRespVO(receiptInvoiceDO);
if (receiptInvoiceDO.getInvoicerId() != null) {
invoiceInReceiptRespVO.setInvoicerName(adminUserApi.getUserName(receiptInvoiceDO.getInvoicerId().toString()));
if (receiptInvoiceDO != null) {
InvoiceInReceiptRespVO invoiceInReceiptRespVO = ReceiptInvoiceConvert.INSTANCE.convertRespVO(receiptInvoiceDO);
if (receiptInvoiceDO.getInvoicerId() != null) {
invoiceInReceiptRespVO.setInvoicerName(adminUserApi.getUserName(receiptInvoiceDO.getInvoicerId().toString()));
}
invoiceInReceiptRespVO.setInvoice(receiptInvoiceDO.getInvoiceHeader());
invoiceInReceiptRespVO.setAddressPhone(receiptInvoiceDO.getInvoiceAddress());
invoiceInReceiptRespVO.setProjectName(receiptInvoiceDO.getInvoiceItem());
backVO.setInvoiceVO(invoiceInReceiptRespVO);
}
invoiceInReceiptRespVO.setInvoice(receiptInvoiceDO.getInvoiceHeader());
invoiceInReceiptRespVO.setAddressPhone(receiptInvoiceDO.getInvoiceAddress());
invoiceInReceiptRespVO.setProjectName(receiptInvoiceDO.getInvoiceItem());
backVO.setInvoiceVO(invoiceInReceiptRespVO);
}
backVO.setCreator(adminUserApi.getUserName(receiptDO.getCreator()));
backVO.setUpdater(adminUserApi.getUserName(receiptDO.getUpdater()));
......
......@@ -31,6 +31,7 @@ import cn.iocoder.yudao.module.wealth.vo.receivable.ReceivableBackVO;
import cn.iocoder.yudao.module.wealth.vo.receivable.WealthMoneyAmountVO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
......@@ -86,6 +87,13 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
}
// 校验收款单状态
checkReceiptForCreateInvoice(receiptDO);
// 检查之前是否有取消的开票信息
ReceiptInvoiceDO canceledInvoice = receiptInvoiceMapper.selectOne(Wrappers.lambdaQuery(ReceiptInvoiceDO.class)
.eq(ReceiptInvoiceDO::getReceiptId, receiptDO.getId())
.isNotNull(ReceiptInvoiceDO::getCancelUserId));
if (canceledInvoice != null) {
receiptInvoiceMapper.deleteById(canceledInvoice.getId());
}
// 创建开票资料
ReceiptInvoiceDO receiptInvoiceDO = ReceiptInvoiceConvert.INSTANCE.convert(createReqVO);
receiptInvoiceDO.setInvoiceNo(wealthGenCodeUtils.generateInvoiceCode());
......@@ -278,6 +286,7 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptDO.setId(receiptInvoiceDO.getReceiptId());
receiptDO.setOpenInvoice(0);
receiptDO.setInvoicingStatus(CANCELLED.getValue());
receiptDO.setInvoiceDataStatus(REJECT.getValue());
receiptMapper.updateById(receiptDO);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
receiptInvoiceDO.setCancelUserId(loginUser.getId());
......@@ -312,8 +321,8 @@ public class ReceiptInvoiceServiceImpl extends AbstractService<ReceiptInvoiceMap
receiptDO.setId(receiptInvoiceDO.getReceiptId());
receiptDO.setInvoicingStatus(InvoicingStatusEnum.WAIT.getValue());
receiptMapper.updateById(receiptDO);
recordLog(receiptInvoiceDO.getReceiptId(), InvoicingLinkEnum.DELETE_INVOICE_INFO, reqVO.getRemark(), null);
return null;
recordLog(receiptInvoiceDO.getId(), InvoicingLinkEnum.DELETE_INVOICE_INFO, reqVO.getRemark(), null);
return true;
}
/**
......
......@@ -577,9 +577,6 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
if (ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue() == receiptDO.getState()) {
throw exception(RECEIPT_WRITE_OFF_ALL_SUCCESS_ITEM_NOT_APPROVE);
}
if (ReceiptStatusEnum.WRITE_OFF_ALL_OPENING.getValue() == receiptDO.getState()) {
throw exception(RECEIPT_WRITE_OFF_ALL_SUCCESS_ITEM_NOT_APPROVE);
}
if (ReceiptStatusEnum.OPEN_BILL.getValue() == receiptDO.getState()) {
throw exception(RECEIPT_WRITE_OFF_ALL_SUCCESS_ITEM_NOT_APPROVE);
}
......@@ -839,7 +836,7 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
Map<Long, List<ReceivableDO>> receivableCollect = receivableDOS.stream().filter(receivableDO -> receivableDO.getReceiptId() != null).collect(Collectors.groupingBy(ReceivableDO::getReceiptId));
ReceiptDO matchReceiptDO = receivableCollect.keySet().stream()
.map(receiptId -> receiptService.selectOne("id", receiptId))
.filter(receivableDO -> !Objects.equals(receivableDO.getState(), ReceiptStatusEnum.DRAFT.getValue()) && !Objects.equals(receivableDO.getState(), ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue()) && !Objects.equals(receivableDO.getState(), ReceiptStatusEnum.WRITE_OFF_ALL_OPENING.getValue()))
.filter(receivableDO -> !Objects.equals(receivableDO.getState(), ReceiptStatusEnum.DRAFT.getValue()) && !Objects.equals(receivableDO.getState(), ReceiptStatusEnum.WRITE_OFF_ALL_SUCCESS.getValue()))
.max(Comparator.comparingLong(r -> r.getCreateTime().getTime()))
.orElse(null);
if (null == matchReceiptDO) {
......
......@@ -634,7 +634,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
receivableInItemVO.setWriteOffAmountUsd(totalWriteOffAmount);
receivableInItemVO.setNotWriteOffAmountUsd(receivableInItemVO.getBaseAmount().subtract(totalWriteOffAmount));
}
receivableInItemVOS.sort(Comparator.comparing(ReceivableInItemVO::getNotWriteOffAmountUsd).reversed());
receivableInItemVOS.sort(Comparator.comparing(ReceivableInItemVO::getNotWriteOffAmountUsd));
return receivableInItemVOS;
}
......@@ -660,7 +660,7 @@ public class ReceivableServiceImpl extends AbstractService<ReceivableMapper, Rec
}
receivableInItemVO.setNotWriteOffAmountUsd(receivableInItemVO.getBaseAmount().subtract(receivableInItemVO.getWriteOffAmountUsd()));
}
receivableInItemVOS.sort(Comparator.comparing(ReceivableInItemVO::getNotWriteOffAmountUsd).reversed());
receivableInItemVOS.sort(Comparator.comparing(ReceivableInItemVO::getNotWriteOffAmountUsd));
return receivableInItemVOS;
}
......
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