调整收付款问题
This commit is contained in:
+4
-2
@@ -82,9 +82,11 @@ public class InvoiceApplicationController extends BladeController {
|
|||||||
@Operation(summary = "可开票正式结算单")
|
@Operation(summary = "可开票正式结算单")
|
||||||
public R<IPage<Map<String, Object>>> settlementCandidates(Query query,
|
public R<IPage<Map<String, Object>>> settlementCandidates(Query query,
|
||||||
@RequestParam(required = false) String keyword,
|
@RequestParam(required = false) String keyword,
|
||||||
@RequestParam(required = false) String contractCategory) {
|
@RequestParam(required = false) String contractCategory,
|
||||||
|
@RequestParam(defaultValue = "receivable") String settlementType,
|
||||||
|
@RequestParam(defaultValue = "unreceived") String invoiceStatus) {
|
||||||
return R.data(invoiceApplicationService.settlementCandidates(
|
return R.data(invoiceApplicationService.settlementCandidates(
|
||||||
Condition.getPage(query), keyword, contractCategory));
|
Condition.getPage(query), keyword, contractCategory, settlementType, invoiceStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/settlement-details")
|
@GetMapping("/settlement-details")
|
||||||
|
|||||||
+2
-1
@@ -44,7 +44,8 @@ import java.util.Map;
|
|||||||
public interface IInvoiceApplicationService extends BaseService<InvoiceApplication> {
|
public interface IInvoiceApplicationService extends BaseService<InvoiceApplication> {
|
||||||
IPage<InvoiceApplicationVO> selectPage(IPage<InvoiceApplication> page, InvoiceApplicationVO query);
|
IPage<InvoiceApplicationVO> selectPage(IPage<InvoiceApplication> page, InvoiceApplicationVO query);
|
||||||
InvoiceApplicationVO detail(Long id);
|
InvoiceApplicationVO detail(Long id);
|
||||||
IPage<Map<String, Object>> settlementCandidates(IPage<?> page, String keyword, String contractCategory);
|
IPage<Map<String, Object>> settlementCandidates(IPage<?> page, String keyword, String contractCategory,
|
||||||
|
String settlementType, String invoiceStatus);
|
||||||
List<FormalSettlementDetail> settlementDetails(String settlementIds);
|
List<FormalSettlementDetail> settlementDetails(String settlementIds);
|
||||||
Map<String, Object> receiverInformation(String settlementIds);
|
Map<String, Object> receiverInformation(String settlementIds);
|
||||||
Long saveDraft(InvoiceApplicationSaveRequest request);
|
Long saveDraft(InvoiceApplicationSaveRequest request);
|
||||||
|
|||||||
+17
-9
@@ -147,7 +147,9 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<Map<String, Object>> settlementCandidates(IPage<?> page, String keyword,
|
public IPage<Map<String, Object>> settlementCandidates(IPage<?> page, String keyword,
|
||||||
String contractCategory) {
|
String contractCategory, String settlementType, String invoiceStatus) {
|
||||||
|
String candidateSettlementType = Func.isEmpty(settlementType) ? "receivable" : settlementType;
|
||||||
|
String candidateInvoiceStatus = Func.isEmpty(invoiceStatus) ? "unreceived" : invoiceStatus;
|
||||||
List<Long> contractIds = Func.isEmpty(contractCategory) ? List.of()
|
List<Long> contractIds = Func.isEmpty(contractCategory) ? List.of()
|
||||||
: contractManageMapper.selectList(Wrappers.<ContractManage>lambdaQuery()
|
: contractManageMapper.selectList(Wrappers.<ContractManage>lambdaQuery()
|
||||||
.select(ContractManage::getId)
|
.select(ContractManage::getId)
|
||||||
@@ -158,7 +160,8 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
|||||||
return new Page<>(page.getCurrent(), page.getSize(), 0);
|
return new Page<>(page.getCurrent(), page.getSize(), 0);
|
||||||
}
|
}
|
||||||
List<FormalSettlement> settlements = formalSettlementMapper.selectList(Wrappers.<FormalSettlement>lambdaQuery()
|
List<FormalSettlement> settlements = formalSettlementMapper.selectList(Wrappers.<FormalSettlement>lambdaQuery()
|
||||||
.eq(FormalSettlement::getSettlementType, "payable")
|
.eq(FormalSettlement::getSettlementType, candidateSettlementType)
|
||||||
|
.eq(FormalSettlement::getInvoiceStatus, candidateInvoiceStatus)
|
||||||
.eq(FormalSettlement::getApprovalStatus, APPROVED)
|
.eq(FormalSettlement::getApprovalStatus, APPROVED)
|
||||||
.eq(FormalSettlement::getStatus, 1)
|
.eq(FormalSettlement::getStatus, 1)
|
||||||
.in(Func.isNotEmpty(contractCategory), FormalSettlement::getContractId, contractIds)
|
.in(Func.isNotEmpty(contractCategory), FormalSettlement::getContractId, contractIds)
|
||||||
@@ -243,13 +246,15 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
|||||||
List<FormalSettlement> settlements = distinctIds(settlementIds).stream().map(this::availableSettlement).toList();
|
List<FormalSettlement> settlements = distinctIds(settlementIds).stream().map(this::availableSettlement).toList();
|
||||||
assertCompatible(settlements);
|
assertCompatible(settlements);
|
||||||
FormalSettlement first = settlements.get(0);
|
FormalSettlement first = settlements.get(0);
|
||||||
CustomerArchive customer = findCustomer(first.getPayeeName());
|
String customerName = "receivable".equals(first.getSettlementType())
|
||||||
|
? first.getPayerName() : first.getPayeeName();
|
||||||
|
CustomerArchive customer = findCustomer(customerName);
|
||||||
List<CustomerInvoiceInfo> invoiceInfos = customer == null ? List.of() : activeInvoiceInfos(customer.getId());
|
List<CustomerInvoiceInfo> invoiceInfos = customer == null ? List.of() : activeInvoiceInfos(customer.getId());
|
||||||
Map<String, Object> result = new LinkedHashMap<>();
|
Map<String, Object> result = new LinkedHashMap<>();
|
||||||
result.put("issuerName", first.getPayeeName());
|
result.put("issuerName", first.getPayeeName());
|
||||||
result.put("receiverName", first.getPayerName());
|
result.put("receiverName", first.getPayerName());
|
||||||
result.put("customer", customer);
|
result.put("customer", customer);
|
||||||
// 应付结算单的开票方(payeeName)是客商,受票方信息和部门邮箱均来源于该客商发票信息。
|
// 应收结算单的受票方(payerName)是客商;历史应付申请仍按开票方(payeeName)读取客商资料。
|
||||||
result.put("invoices", invoiceInfos);
|
result.put("invoices", invoiceInfos);
|
||||||
result.put("invoiceInfos", invoiceInfos);
|
result.put("invoiceInfos", invoiceInfos);
|
||||||
result.put("departmentEmails", invoiceInfoEmails(invoiceInfos));
|
result.put("departmentEmails", invoiceInfoEmails(invoiceInfos));
|
||||||
@@ -274,6 +279,10 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
|||||||
.collect(Collectors.toMap(InvoiceApplicationSaveRequest.SettlementRow::getSettlementId,
|
.collect(Collectors.toMap(InvoiceApplicationSaveRequest.SettlementRow::getSettlementId,
|
||||||
Function.identity(), (first, duplicate) -> first, LinkedHashMap::new)).values().stream().toList();
|
Function.identity(), (first, duplicate) -> first, LinkedHashMap::new)).values().stream().toList();
|
||||||
List<FormalSettlement> settlements = requestedRows.stream().map(row -> availableSettlement(row.getSettlementId())).toList();
|
List<FormalSettlement> settlements = requestedRows.stream().map(row -> availableSettlement(row.getSettlementId())).toList();
|
||||||
|
if (settlements.stream().anyMatch(settlement -> !"receivable".equals(settlement.getSettlementType())
|
||||||
|
|| (creating && !"unreceived".equals(settlement.getInvoiceStatus())))) {
|
||||||
|
throw new ServiceException("只能选择审批通过、未作废、未收票的应收正式结算单");
|
||||||
|
}
|
||||||
assertCompatible(settlements);
|
assertCompatible(settlements);
|
||||||
FormalSettlement first = settlements.get(0);
|
FormalSettlement first = settlements.get(0);
|
||||||
Map<Long, FormalSettlement> settlementMap = settlements.stream()
|
Map<Long, FormalSettlement> settlementMap = settlements.stream()
|
||||||
@@ -292,8 +301,8 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
|||||||
if (lineTotal.compareTo(BigDecimal.ZERO) <= 0) {
|
if (lineTotal.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
throw new ServiceException("本次开票金额必须大于0");
|
throw new ServiceException("本次开票金额必须大于0");
|
||||||
}
|
}
|
||||||
CustomerArchive customer = findCustomer(first.getPayeeName());
|
CustomerArchive customer = findCustomer(first.getPayerName());
|
||||||
if (customer == null) throw new ServiceException("未找到正式结算单开票方对应的客商档案");
|
if (customer == null) throw new ServiceException("未找到正式结算单受票方对应的客商档案");
|
||||||
List<CustomerInvoiceInfo> invoiceInfos = activeInvoiceInfos(customer.getId());
|
List<CustomerInvoiceInfo> invoiceInfos = activeInvoiceInfos(customer.getId());
|
||||||
CustomerInvoiceInfo invoiceInfo = invoiceInfos.stream()
|
CustomerInvoiceInfo invoiceInfo = invoiceInfos.stream()
|
||||||
.filter(item -> Objects.equals(item.getId(), request.getReceiverInvoiceInfoId()))
|
.filter(item -> Objects.equals(item.getId(), request.getReceiverInvoiceInfoId()))
|
||||||
@@ -475,9 +484,8 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
|||||||
if (id == null) throw new ServiceException("正式结算单不能为空");
|
if (id == null) throw new ServiceException("正式结算单不能为空");
|
||||||
FormalSettlement settlement = formalSettlementMapper.selectById(id);
|
FormalSettlement settlement = formalSettlementMapper.selectById(id);
|
||||||
if (settlement == null || Objects.equals(settlement.getIsDeleted(), 1)) throw new ServiceException("正式结算单不存在");
|
if (settlement == null || Objects.equals(settlement.getIsDeleted(), 1)) throw new ServiceException("正式结算单不存在");
|
||||||
if (!Objects.equals(settlement.getStatus(), 1) || !APPROVED.equals(settlement.getApprovalStatus())
|
if (!Objects.equals(settlement.getStatus(), 1) || !APPROVED.equals(settlement.getApprovalStatus())) {
|
||||||
|| !"payable".equals(settlement.getSettlementType())) {
|
throw new ServiceException("只能选择审批通过、未作废的正式结算单");
|
||||||
throw new ServiceException("只能选择审批通过、未作废的应付正式结算单");
|
|
||||||
}
|
}
|
||||||
return settlement;
|
return settlement;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user