✨ 支持生成账单时选择收款账户
This commit is contained in:
+7
@@ -167,6 +167,13 @@ public class ArBillController extends BaseController {
|
|||||||
return success(account);
|
return success(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 生成账单时选择同币种启用账户,账号只返回脱敏值。 */
|
||||||
|
@PreAuthorize("@ss.hasPermi('ar:bill:generate')")
|
||||||
|
@GetMapping("/bank-account-options")
|
||||||
|
public AjaxResult bankAccountOptions(@RequestParam(defaultValue = "CNY") String currency) {
|
||||||
|
return success(billService.selectMaskedBankAccounts(currency));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询生成账单前的订单计费结果。
|
* 查询生成账单前的订单计费结果。
|
||||||
*/
|
*/
|
||||||
|
|||||||
+116
@@ -0,0 +1,116 @@
|
|||||||
|
package com.bms.receivable;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.ArgumentMatchers.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.bms.common.core.domain.model.LoginUser;
|
||||||
|
import com.bms.common.exception.ServiceException;
|
||||||
|
import com.bms.customer.customerinfo.domain.BmsCustomerOption;
|
||||||
|
import com.bms.customer.customerinfo.mapper.BmsCustomerMapper;
|
||||||
|
import com.bms.receivable.domain.ArBankAccount;
|
||||||
|
import com.bms.receivable.domain.ArBill;
|
||||||
|
import com.bms.receivable.domain.vo.ArBillGenerateRequest;
|
||||||
|
import com.bms.receivable.mapper.ArBankAccountMapper;
|
||||||
|
import com.bms.receivable.mapper.ArBillGenerateTaskMapper;
|
||||||
|
import com.bms.receivable.mapper.ArBillMapper;
|
||||||
|
import com.bms.receivable.security.ArBillScopeResolver;
|
||||||
|
import com.bms.receivable.service.IArBillLogService;
|
||||||
|
import com.bms.receivable.service.impl.ArBillServiceImpl;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
|
||||||
|
class ArBillGenerateBankAccountTest {
|
||||||
|
private final ArBillServiceImpl service = new ArBillServiceImpl();
|
||||||
|
private final ArBillMapper bills = mock(ArBillMapper.class);
|
||||||
|
private final ArBankAccountMapper accounts = mock(ArBankAccountMapper.class);
|
||||||
|
private final ArBillGenerateTaskMapper tasks = mock(ArBillGenerateTaskMapper.class);
|
||||||
|
private final ArBillScopeResolver scope = mock(ArBillScopeResolver.class);
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
LoginUser login = new LoginUser();
|
||||||
|
login.setUserId(1L);
|
||||||
|
SecurityContextHolder.getContext().setAuthentication(new UsernamePasswordAuthenticationToken(login, null, List.of()));
|
||||||
|
ReflectionTestUtils.setField(service, "billMapper", bills);
|
||||||
|
ReflectionTestUtils.setField(service, "bankAccountMapper", accounts);
|
||||||
|
ReflectionTestUtils.setField(service, "generateTaskMapper", tasks);
|
||||||
|
ReflectionTestUtils.setField(service, "billScope", scope);
|
||||||
|
ReflectionTestUtils.setField(service, "customerMapper", mock(BmsCustomerMapper.class));
|
||||||
|
ReflectionTestUtils.setField(service, "eventPublisher", mock(ApplicationEventPublisher.class));
|
||||||
|
ReflectionTestUtils.setField(service, "logService", mock(IArBillLogService.class));
|
||||||
|
BmsCustomerOption customer = new BmsCustomerOption();
|
||||||
|
customer.setCustomerCode("C1");
|
||||||
|
customer.setCustomerName("客户");
|
||||||
|
when(scope.requireCustomerAccessible(1L)).thenReturn(customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void clearLogin() { SecurityContextHolder.clearContext(); }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void selectedAccountIsValidatedAndSavedAsBillSnapshot() {
|
||||||
|
ArBankAccount account = account("CNY");
|
||||||
|
when(accounts.selectEnabledById(9L)).thenReturn(account);
|
||||||
|
ArBillGenerateRequest request = request();
|
||||||
|
request.setBankAccountId(9L);
|
||||||
|
request.setBankAccountNo("前端伪造的账号");
|
||||||
|
service.generateBill(request, "admin", "request-1");
|
||||||
|
|
||||||
|
ArgumentCaptor<ArBill> saved = ArgumentCaptor.forClass(ArBill.class);
|
||||||
|
verify(bills).insertArBill(saved.capture());
|
||||||
|
assertEquals(account.getAccountName(), saved.getValue().getBankAccountName());
|
||||||
|
assertEquals(account.getAccountNo(), saved.getValue().getBankAccountNo());
|
||||||
|
assertEquals(account.getBankName(), saved.getValue().getBankName());
|
||||||
|
verify(accounts, never()).selectDefaultByCurrency(anyString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void missingOrWrongCurrencyAccountCannotCreateBillAndOldRequestsUseDefault() {
|
||||||
|
ArBillGenerateRequest request = request();
|
||||||
|
request.setBankAccountId(9L);
|
||||||
|
assertThrows(ServiceException.class, () -> service.generateBill(request, "admin", "missing"));
|
||||||
|
when(accounts.selectEnabledById(9L)).thenReturn(account("USD"));
|
||||||
|
assertThrows(ServiceException.class, () -> service.generateBill(request, "admin", "wrong-currency"));
|
||||||
|
verify(bills, never()).insertArBill(any());
|
||||||
|
|
||||||
|
request.setBankAccountId(null);
|
||||||
|
when(accounts.selectDefaultByCurrency("CNY")).thenReturn(account("CNY"));
|
||||||
|
assertDoesNotThrow(() -> service.generateBill(request, "admin", "legacy"));
|
||||||
|
verify(accounts).selectDefaultByCurrency("CNY");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void bankAccountOptionsMaskNumbersWithoutSpaces() {
|
||||||
|
ArBankAccount account = account("CNY");
|
||||||
|
when(accounts.selectEnabledList("CNY")).thenReturn(List.of(account));
|
||||||
|
assertEquals("****2050", service.selectMaskedBankAccounts("CNY").get(0).getAccountNo());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArBankAccount account(String currency) {
|
||||||
|
ArBankAccount account = new ArBankAccount();
|
||||||
|
account.setAccountName("收款单位");
|
||||||
|
account.setAccountNo("8602 1110 0008 9205 0");
|
||||||
|
account.setBankName("开户行");
|
||||||
|
account.setCurrency(currency);
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArBillGenerateRequest request() {
|
||||||
|
ArBillGenerateRequest request = new ArBillGenerateRequest();
|
||||||
|
request.setCustomerId(1L);
|
||||||
|
request.setBillName("测试账单");
|
||||||
|
request.setBillPeriodEnd(Date.valueOf("2026-10-31"));
|
||||||
|
request.setSourceBillIds(List.of(1L));
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -111,6 +111,41 @@ class ArBillTemplateSelectionTest {
|
|||||||
assertEquals("应收账单汇总模板", options.get(0).getTemplateName());
|
assertEquals("应收账单汇总模板", options.get(0).getTemplateName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void fixedPayeeTemplatesRejectMismatchesBeforeCreatingExportTasks() {
|
||||||
|
ArExportTemplate fixed = template(3L, ArBillWorkbookWriters.GUANGZHOU_TEMPLATE_CODE);
|
||||||
|
fixed.setStorageKey("templates/receivable/ar_bill_template_gz.xlsx");
|
||||||
|
when(templates.selectEnabledById(3L, "AR_BILL", bill.getBillDate())).thenReturn(fixed);
|
||||||
|
bill.setBankAccountName("威狮国际供应链(深圳)有限公司广州分公司");
|
||||||
|
bill.setBankAccountNo("44050129162500001250");
|
||||||
|
bill.setBankName("中国建设银行股份有限公司广州设计之都支行");
|
||||||
|
assertEquals(3L, service.exportBill(7L, 3L, "admin", "matching").getTemplateId());
|
||||||
|
|
||||||
|
bill.setBankAccountNo("1234567890");
|
||||||
|
ServiceException error = assertThrows(ServiceException.class,
|
||||||
|
() -> service.exportBill(7L, 3L, "admin", "mismatch"));
|
||||||
|
assertTrue(error.getMessage().contains("收款信息"));
|
||||||
|
verify(exports, times(1)).insert(any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void fixedPayeeTemplateValidationChecksNameAccountAndBankForBothTemplates() {
|
||||||
|
ArBillWorkbookWriters writers = new ArBillWorkbookWriters(new DefaultArBillWorkbookWriter(), new SummaryArBillWorkbookWriter());
|
||||||
|
ArExportTemplate fixed = template(3L, ArBillWorkbookWriters.JIYUN_TEMPLATE_CODE);
|
||||||
|
fixed.setStorageKey("templates/receivable/ar_bill_template_jy.xlsx");
|
||||||
|
bill.setBankAccountName("威狮国际集运物流(深圳)有限公司");
|
||||||
|
bill.setBankAccountNo("86021110000892050");
|
||||||
|
bill.setBankName("宁波银行深圳后海支行");
|
||||||
|
assertDoesNotThrow(() -> writers.validatePayee(bill, fixed));
|
||||||
|
bill.setBankName("其他银行");
|
||||||
|
assertThrows(ServiceException.class, () -> writers.validatePayee(bill, fixed));
|
||||||
|
bill.setBankName("宁波银行深圳后海支行");
|
||||||
|
bill.setBankAccountName("其他公司");
|
||||||
|
assertThrows(ServiceException.class, () -> writers.validatePayee(bill, fixed));
|
||||||
|
bill.setBankAccountName(null);
|
||||||
|
assertThrows(ServiceException.class, () -> writers.validatePayee(bill, fixed));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void mapperQueriesEnforceBusinessStatusEffectiveDatesAndTaskTemplate() throws Exception {
|
void mapperQueriesEnforceBusinessStatusEffectiveDatesAndTaskTemplate() throws Exception {
|
||||||
Configuration configuration = new Configuration();
|
Configuration configuration = new Configuration();
|
||||||
|
|||||||
+2
@@ -40,6 +40,8 @@ public class ArBillGenerateRequest
|
|||||||
@JsonDeserialize(using = StrictDateDeserializer.class)
|
@JsonDeserialize(using = StrictDateDeserializer.class)
|
||||||
private Date billDate;
|
private Date billDate;
|
||||||
private String currency = "CNY";
|
private String currency = "CNY";
|
||||||
|
/** 收款账户配置 ID;旧调用方未传时沿用币种默认账户。 */
|
||||||
|
private Long bankAccountId;
|
||||||
/** 订单号、运单号或转单号原始输入,生成时会拆分并再次校验筛选条件。 */
|
/** 订单号、运单号或转单号原始输入,生成时会拆分并再次校验筛选条件。 */
|
||||||
private String orderOrTrackingNo;
|
private String orderOrTrackingNo;
|
||||||
private String bankAccountName;
|
private String bankAccountName;
|
||||||
|
|||||||
+16
@@ -1,5 +1,8 @@
|
|||||||
package com.bms.receivable.export;
|
package com.bms.receivable.export;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import com.bms.common.exception.ServiceException;
|
||||||
|
import com.bms.receivable.domain.ArBill;
|
||||||
import com.bms.receivable.domain.ArExportTemplate;
|
import com.bms.receivable.domain.ArExportTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -24,4 +27,17 @@ public class ArBillWorkbookWriters {
|
|||||||
public boolean isSummary(ArExportTemplate template) {
|
public boolean isSummary(ArExportTemplate template) {
|
||||||
return SUMMARY_TEMPLATE_CODE.equals(template.getTemplateCode());
|
return SUMMARY_TEMPLATE_CODE.equals(template.getTemplateCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 固定收款信息的模板必须与账单快照一致,避免导出错误的收款账户。 */
|
||||||
|
public void validatePayee(ArBill bill, ArExportTemplate template) {
|
||||||
|
if (!GUANGZHOU_TEMPLATE_CODE.equals(template.getTemplateCode())
|
||||||
|
&& !JIYUN_TEMPLATE_CODE.equals(template.getTemplateCode())) return;
|
||||||
|
try {
|
||||||
|
if (!defaultWriter.matchesTemplatePayee(bill, template)) {
|
||||||
|
throw new ServiceException("所选模板的固定收款信息与账单收款账户不一致,请选择匹配的模板");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServiceException("无法读取所选模板的收款信息,请检查模板配置");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
@@ -19,8 +19,10 @@ import java.util.zip.ZipOutputStream;
|
|||||||
import org.apache.poi.ss.usermodel.BuiltinFormats;
|
import org.apache.poi.ss.usermodel.BuiltinFormats;
|
||||||
import org.apache.poi.ss.usermodel.FillPatternType;
|
import org.apache.poi.ss.usermodel.FillPatternType;
|
||||||
import org.apache.poi.ss.usermodel.IndexedColors;
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
||||||
|
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||||
import org.apache.poi.xssf.model.StylesTable;
|
import org.apache.poi.xssf.model.StylesTable;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import com.bms.common.utils.StringUtils;
|
import com.bms.common.utils.StringUtils;
|
||||||
import com.bms.receivable.domain.ArBill;
|
import com.bms.receivable.domain.ArBill;
|
||||||
@@ -71,6 +73,28 @@ public class DefaultArBillWorkbookWriter extends ArBillWorkbookSupport {
|
|||||||
int formula, int failedFormula) {
|
int formula, int failedFormula) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 首表 C7:C9 是固定开户名、账号和开户行;空值不得通过匹配。 */
|
||||||
|
public boolean matchesTemplatePayee(ArBill bill, ArExportTemplate template) throws IOException {
|
||||||
|
try (InputStream input = openTemplateStream(template); XSSFWorkbook workbook = new XSSFWorkbook(input)) {
|
||||||
|
if (workbook.getNumberOfSheets() == 0) return false;
|
||||||
|
var sheet = workbook.getSheetAt(0);
|
||||||
|
DataFormatter formatter = new DataFormatter();
|
||||||
|
String[] expected = {bill.getBankAccountName(), bill.getBankAccountNo(), bill.getBankName()};
|
||||||
|
for (int i = 0; i < expected.length; i++) {
|
||||||
|
var row = sheet.getRow(6 + i);
|
||||||
|
var cell = row == null ? null : row.getCell(2);
|
||||||
|
String actual = cell == null ? "" : formatter.formatCellValue(cell);
|
||||||
|
String snapshot = normalizePayeeValue(expected[i]);
|
||||||
|
if (snapshot.isEmpty() || !snapshot.equals(normalizePayeeValue(actual))) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizePayeeValue(String value) {
|
||||||
|
return value == null ? "" : value.replaceAll("[\\s\\p{Z}]+", "");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ArBill bill, ArExportTemplate template, Path target) throws IOException {
|
public void write(ArBill bill, ArExportTemplate template, Path target) throws IOException {
|
||||||
// 样式表单独读取;不加载整张工作簿,且不依赖 styles.xml 和 sheet1.xml 在 ZIP 中的先后顺序。
|
// 样式表单独读取;不加载整张工作簿,且不依赖 styles.xml 和 sheet1.xml 在 ZIP 中的先后顺序。
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public interface IArBillService
|
|||||||
|
|
||||||
List<ArBankAccount> selectEnabledBankAccounts(String currency);
|
List<ArBankAccount> selectEnabledBankAccounts(String currency);
|
||||||
|
|
||||||
|
List<ArBankAccount> selectMaskedBankAccounts(String currency);
|
||||||
|
|
||||||
List<PrcOrderBill> previewBill(ArBillGenerateQuery query);
|
List<PrcOrderBill> previewBill(ArBillGenerateQuery query);
|
||||||
|
|
||||||
List<PrcOrderBill> previewBill(ArBillGenerateQuery query, ArBillRowScope scope);
|
List<PrcOrderBill> previewBill(ArBillGenerateQuery query, ArBillRowScope scope);
|
||||||
|
|||||||
+19
-3
@@ -261,6 +261,13 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
return accounts;
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ArBankAccount> selectMaskedBankAccounts(String currency) {
|
||||||
|
List<ArBankAccount> accounts = selectEnabledBankAccounts(currency);
|
||||||
|
accounts.forEach(account -> account.setAccountNo(maskAccount(account.getAccountNo())));
|
||||||
|
return accounts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页预览可生成订单;多个订单号、运单号或转单号按 OR 条件精确匹配。
|
* 分页预览可生成订单;多个订单号、运单号或转单号按 OR 条件精确匹配。
|
||||||
*/
|
*/
|
||||||
@@ -383,10 +390,16 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
if (generatingBill != null) {
|
if (generatingBill != null) {
|
||||||
throw new ServiceException("该客户当前账期已有账单正在生成,请稍后再试");
|
throw new ServiceException("该客户当前账期已有账单正在生成,请稍后再试");
|
||||||
}
|
}
|
||||||
ArBankAccount bankAccount = bankAccountMapper.selectDefaultByCurrency(currency);
|
ArBankAccount bankAccount = request.getBankAccountId() == null
|
||||||
|
? bankAccountMapper.selectDefaultByCurrency(currency)
|
||||||
|
: bankAccountMapper.selectEnabledById(request.getBankAccountId());
|
||||||
if (bankAccount == null) {
|
if (bankAccount == null) {
|
||||||
throw failure(null, ArLogObjectType.BILL, "", ArLogOperationType.GENERATE, null,
|
throw failure(null, ArLogObjectType.BILL, "", ArLogOperationType.GENERATE, null,
|
||||||
"未配置 " + currency + " 币种的公司默认收款账户,请先完成收款账户配置", operator, requestId);
|
request.getBankAccountId() == null ? "未配置 " + currency + " 币种的公司默认收款账户,请先完成收款账户配置"
|
||||||
|
: "所选收款账户不存在或已停用,请重新选择", operator, requestId);
|
||||||
|
}
|
||||||
|
if (!currency.equalsIgnoreCase(bankAccount.getCurrency())) {
|
||||||
|
throw new ServiceException("所选收款账户币种与账单币种不一致,请重新选择");
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
@@ -1038,6 +1051,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
bill.getStatus(), templateId == null ? "未配置启用中的应收账单默认导出模板"
|
bill.getStatus(), templateId == null ? "未配置启用中的应收账单默认导出模板"
|
||||||
: "所选应收账单模板不存在、已停用或不在生效期内,请重新选择", operator, requestId);
|
: "所选应收账单模板不存在、已停用或不在生效期内,请重新选择", operator, requestId);
|
||||||
}
|
}
|
||||||
|
workbookWriters.validatePayee(bill, template);
|
||||||
ArBillExport processing = exportMapper.selectProcessingByBillAndTemplate(arBillId, template.getTemplateId());
|
ArBillExport processing = exportMapper.selectProcessingByBillAndTemplate(arBillId, template.getTemplateId());
|
||||||
if (processing != null) {
|
if (processing != null) {
|
||||||
log.info("应收账单导出任务已存在,operator={}, requestId={}, arBillId={}, exportId={}, status={}, costMs={}",
|
log.info("应收账单导出任务已存在,operator={}, requestId={}, arBillId={}, exportId={}, status={}, costMs={}",
|
||||||
@@ -1115,6 +1129,7 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
String objectKey = "ar/bill/" + DateUtils.datePath() + "/" + IdUtils.fastSimpleUUID() + ".xlsx";
|
String objectKey = "ar/bill/" + DateUtils.datePath() + "/" + IdUtils.fastSimpleUUID() + ".xlsx";
|
||||||
temp = Files.createTempFile("ar-bill-export-", ".xlsx");
|
temp = Files.createTempFile("ar-bill-export-", ".xlsx");
|
||||||
ArExportTemplate template = resolveExportTemplate(export, bill);
|
ArExportTemplate template = resolveExportTemplate(export, bill);
|
||||||
|
workbookWriters.validatePayee(bill, template);
|
||||||
workbookWriters.select(template).write(bill, template, temp);
|
workbookWriters.select(template).write(bill, template, temp);
|
||||||
export.setFileSize(Files.size(temp));
|
export.setFileSize(Files.size(temp));
|
||||||
export.setFileHash(sha256(temp));
|
export.setFileHash(sha256(temp));
|
||||||
@@ -1359,7 +1374,8 @@ public class ArBillServiceImpl implements IArBillService {
|
|||||||
|
|
||||||
private String maskAccount(String value) {
|
private String maskAccount(String value) {
|
||||||
if (StringUtils.isEmpty(value)) return "";
|
if (StringUtils.isEmpty(value)) return "";
|
||||||
return value.length() <= 4 ? "****" : "****" + value.substring(value.length() - 4);
|
String normalized = value.replaceAll("[\\s\\p{Z}]+", "");
|
||||||
|
return normalized.length() <= 4 ? "****" : "****" + normalized.substring(normalized.length() - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sha256(Path file) throws IOException, NoSuchAlgorithmException {
|
private String sha256(Path file) throws IOException, NoSuchAlgorithmException {
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ export function getDefaultArBankAccount(currency = 'CNY') {
|
|||||||
return request({ url: '/ar/bill/default-bank-account', method: 'get', params: { currency } })
|
return request({ url: '/ar/bill/default-bank-account', method: 'get', params: { currency } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function listArBillBankAccountOptions(currency = 'CNY') {
|
||||||
|
return request({ url: '/ar/bill/bank-account-options', method: 'get', params: { currency } })
|
||||||
|
}
|
||||||
|
|
||||||
export function generateArBill(data) {
|
export function generateArBill(data) {
|
||||||
return request({ url: '/ar/bill/generate', method: 'post', data, timeout: 30000 })
|
return request({ url: '/ar/bill/generate', method: 'post', data, timeout: 30000 })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,13 +32,16 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div class="payee-card" v-loading="bankAccountLoading">
|
<div class="payee-card" v-loading="bankAccountLoading">
|
||||||
<div class="payee-title">收款方信息(按币种自动匹配)</div>
|
<div class="payee-title">收款方信息</div>
|
||||||
|
<el-select v-model="selectedBankAccountId" class="payee-select" placeholder="请选择收款账户" :disabled="bankAccountLoading || generateLoading" @change="handleBankAccountChange">
|
||||||
|
<el-option v-for="account in bankAccounts" :key="account.bankAccountId" :value="String(account.bankAccountId)" :label="`${account.accountName}(${account.accountNo})`" />
|
||||||
|
</el-select>
|
||||||
<template v-if="bankAccount">
|
<template v-if="bankAccount">
|
||||||
<span><b>开户名:</b>{{ bankAccount.accountName }}</span>
|
<span><b>开户名:</b>{{ bankAccount.accountName }}</span>
|
||||||
<span><b>开户行:</b>{{ bankAccount.bankName }}</span>
|
<span><b>开户行:</b>{{ bankAccount.bankName }}</span>
|
||||||
<span><b>账号:</b>{{ bankAccount.accountNo }}</span>
|
<span><b>账号:</b>{{ bankAccount.accountNo }}</span>
|
||||||
</template>
|
</template>
|
||||||
<span v-else class="payee-empty">当前币种尚未配置公司默认收款账户</span>
|
<span v-else-if="!bankAccountLoading" class="payee-empty">当前币种尚未配置启用的收款账户</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="preview-toolbar">
|
<div class="preview-toolbar">
|
||||||
<span v-if="previewSearched" class="preview-summary">
|
<span v-if="previewSearched" class="preview-summary">
|
||||||
@@ -177,7 +180,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="GenerateBillDialog">
|
<script setup name="GenerateBillDialog">
|
||||||
import { listArBillGenerateCustomerOptions, getDefaultArBankAccount, previewArBill, getArBillPreviewAmount, previewExcludedArBill, generateArBill } from '@/api/ar/bill'
|
import { listArBillGenerateCustomerOptions, listArBillBankAccountOptions, previewArBill, getArBillPreviewAmount, previewExcludedArBill, generateArBill } from '@/api/ar/bill'
|
||||||
import { Download, Refresh, Search, Select } from '@element-plus/icons-vue'
|
import { Download, Refresh, Search, Select } from '@element-plus/icons-vue'
|
||||||
import { AR_BILL_SELECTION_MODE } from '@/constants/ar/enums'
|
import { AR_BILL_SELECTION_MODE } from '@/constants/ar/enums'
|
||||||
import { exportAsync } from '@/utils/excelExport'
|
import { exportAsync } from '@/utils/excelExport'
|
||||||
@@ -255,7 +258,10 @@ let excludeRequestSeq = 0
|
|||||||
const previewQuery = ref(null)
|
const previewQuery = ref(null)
|
||||||
let syncingPageSelection = false
|
let syncingPageSelection = false
|
||||||
const bankAccountLoading = ref(false)
|
const bankAccountLoading = ref(false)
|
||||||
const bankAccount = ref(null)
|
const bankAccounts = ref([])
|
||||||
|
const selectedBankAccountId = ref('')
|
||||||
|
const bankAccount = computed(() => bankAccounts.value.find(account => String(account.bankAccountId) === selectedBankAccountId.value) || null)
|
||||||
|
let bankAccountRequestSeq = 0
|
||||||
const generateRequestId = ref('')
|
const generateRequestId = ref('')
|
||||||
const generateFormRef = ref()
|
const generateFormRef = ref()
|
||||||
const billNameFormRef = ref()
|
const billNameFormRef = ref()
|
||||||
@@ -288,8 +294,7 @@ function openGenerate() {
|
|||||||
Object.assign(billNameForm, { billName: '' })
|
Object.assign(billNameForm, { billName: '' })
|
||||||
billNameOpen.value = false
|
billNameOpen.value = false
|
||||||
resetPreview()
|
resetPreview()
|
||||||
bankAccount.value = null
|
loadBankAccounts()
|
||||||
loadDefaultBankAccount()
|
|
||||||
nextTick(() => generateFormRef.value?.clearValidate())
|
nextTick(() => generateFormRef.value?.clearValidate())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +306,7 @@ function handleCustomerChange(_, item) {
|
|||||||
|
|
||||||
function handleCurrencyChange() {
|
function handleCurrencyChange() {
|
||||||
resetPreview()
|
resetPreview()
|
||||||
loadDefaultBankAccount()
|
loadBankAccounts()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只清空输入内容,不自动刷新预览;用户点击“查询”后再按新条件查询。
|
// 只清空输入内容,不自动刷新预览;用户点击“查询”后再按新条件查询。
|
||||||
@@ -315,16 +320,25 @@ function clearExcludeIdentifiers() {
|
|||||||
invalidateExcludeSearch()
|
invalidateExcludeSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadDefaultBankAccount() {
|
function loadBankAccounts() {
|
||||||
|
const requestSeq = ++bankAccountRequestSeq
|
||||||
bankAccountLoading.value = true
|
bankAccountLoading.value = true
|
||||||
bankAccount.value = null
|
bankAccounts.value = []
|
||||||
getDefaultArBankAccount(generateForm.currency).then(res => {
|
selectedBankAccountId.value = ''
|
||||||
bankAccount.value = res.data || null
|
listArBillBankAccountOptions(generateForm.currency).then(res => {
|
||||||
|
if (requestSeq !== bankAccountRequestSeq) return
|
||||||
|
bankAccounts.value = res.data || []
|
||||||
|
const defaultAccount = bankAccounts.value.find(account => String(account.isDefault) === '1') || bankAccounts.value[0]
|
||||||
|
selectedBankAccountId.value = defaultAccount ? String(defaultAccount.bankAccountId) : ''
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
bankAccountLoading.value = false
|
if (requestSeq === bankAccountRequestSeq) bankAccountLoading.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleBankAccountChange() {
|
||||||
|
if (!generateLoading.value) generateRequestId.value = ''
|
||||||
|
}
|
||||||
|
|
||||||
// 条件变化后清理预览和跨页选中状态;用户点击查询时重新加载第一页。
|
// 条件变化后清理预览和跨页选中状态;用户点击查询时重新加载第一页。
|
||||||
function resetPreview() {
|
function resetPreview() {
|
||||||
previewRows.value = []
|
previewRows.value = []
|
||||||
@@ -363,6 +377,7 @@ function buildGenerateRequest(requestId) {
|
|||||||
return {
|
return {
|
||||||
...(previewQuery.value || buildGenerateQuery()),
|
...(previewQuery.value || buildGenerateQuery()),
|
||||||
billName: billNameForm.billName.trim(),
|
billName: billNameForm.billName.trim(),
|
||||||
|
bankAccountId: selectedBankAccountId.value,
|
||||||
selectionMode: selectionMode.value,
|
selectionMode: selectionMode.value,
|
||||||
sourceBillIds: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED ? [] : selectedRows.value.map(row => String(row.billId)),
|
sourceBillIds: selectionMode.value === AR_BILL_SELECTION_MODE.ALL_MATCHED ? [] : selectedRows.value.map(row => String(row.billId)),
|
||||||
excludedSourceBillIds: [],
|
excludedSourceBillIds: [],
|
||||||
@@ -673,6 +688,7 @@ function createRequestId() { return globalThis.crypto?.randomUUID?.() || `ar-${D
|
|||||||
.order-identifier-clear { position: absolute; top: 4px; right: 6px; z-index: 1; padding: 2px 4px; }
|
.order-identifier-clear { position: absolute; top: 4px; right: 6px; z-index: 1; padding: 2px 4px; }
|
||||||
.payee-card { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; min-height: 42px; margin: 4px 0 12px; padding: 9px 12px; border: 1px solid var(--el-border-color-lighter); border-radius: 4px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); font-size: 13px; }
|
.payee-card { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; min-height: 42px; margin: 4px 0 12px; padding: 9px 12px; border: 1px solid var(--el-border-color-lighter); border-radius: 4px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); font-size: 13px; }
|
||||||
.payee-title { color: var(--el-text-color-primary); font-weight: 600; }
|
.payee-title { color: var(--el-text-color-primary); font-weight: 600; }
|
||||||
|
.payee-select { width: 340px; max-width: 100%; }
|
||||||
.payee-empty { color: var(--el-color-danger); }
|
.payee-empty { color: var(--el-color-danger); }
|
||||||
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 10px; padding: 10px 14px; border-radius: 6px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); }
|
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 10px; padding: 10px 14px; border-radius: 6px; background: var(--el-fill-color-light); color: var(--el-text-color-regular); }
|
||||||
.preview-summary { flex: 1; font-size: 14px; }
|
.preview-summary { flex: 1; font-size: 14px; }
|
||||||
|
|||||||
Reference in New Issue
Block a user