:feat: 金蝶推送客商编码改为经A901-1供应商查询取金蝶编码
This commit is contained in:
+11
-6
@@ -823,8 +823,13 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
String kingdeeOrgNumber = kingdeeApBillSyncSupport.kingdeeOrgNumber(entity.getProjectId(), kingdeeContext);
|
||||
String kingdeeDeptNumber = kingdeeApBillSyncSupport.kingdeeDeptNumber(entity.getProjectId(), kingdeeContext);
|
||||
CustomerArchive customer = entity.getReceiverCustomerId() == null ? null : customerArchiveMapper.selectById(entity.getReceiverCustomerId());
|
||||
if (customer == null || Func.isBlank(customer.getCustomerCode())) {
|
||||
throw new ServiceException("推送金蝶开票申请失败:受票方客户未在客商档案中维护客商编码,请补充后重试");
|
||||
if (customer == null || Func.isBlank(customer.getUnifiedCreditCode())) {
|
||||
throw new ServiceException("推送金蝶开票申请失败:受票方客户未在客商档案中维护统一社会信用代码,请补充后重试");
|
||||
}
|
||||
// 金蝶客商编码:受票方统一社会信用代码 → A901-1 供应商查询取返回值 number
|
||||
String receiverNumber = kingdeeApBillSyncSupport.queryKingdeeSupplierNumber(customer.getUnifiedCreditCode().trim());
|
||||
if (Func.isBlank(receiverNumber)) {
|
||||
throw new ServiceException("推送金蝶开票申请失败:受票方客户[" + customer.getFullName() + "]金蝶侧未查到对应供应商档案,请补充后重试");
|
||||
}
|
||||
// 逐张发票推送金蝶开票申请单:每张发票张次一张(价税合计=本张金额,分录=本张商品行),已存在的张次幂等跳过
|
||||
List<String> savedBillNos = new ArrayList<>();
|
||||
@@ -852,7 +857,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
+ "]无商品行,无法组装分录");
|
||||
}
|
||||
BfiInvoiceApplySaveDTO param = this.buildInvoiceApplyParam(entity, sheetBillNo, seller, salerAddr, salerBank,
|
||||
kingdeeDeptNumber, kingdeeOrgNumber, customer, firstArSrcCode, money(sheet.getInvoiceAmount()), items);
|
||||
kingdeeDeptNumber, kingdeeOrgNumber, receiverNumber, firstArSrcCode, money(sheet.getInvoiceAmount()), items);
|
||||
log.info("金蝶开票申请推送:开票申请[{}]发票张[{}],billno=[{}],价税合计=[{}],分录{}条",
|
||||
entity.getApplicationNo(), sheet.getSheetNo(), sheetBillNo, sheet.getInvoiceAmount(), items.size());
|
||||
BfiBillSaveResultVO saveResult = bfiService.saveInvoiceApply(param);
|
||||
@@ -905,7 +910,7 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
* @param firstArSrcCode 上游来源单据号:首张关联结算单的金蝶应收单防重键 awrp_src_code(多张结算单取第一张)
|
||||
*/
|
||||
private BfiInvoiceApplySaveDTO buildInvoiceApplyParam(InvoiceApplication entity, String billNo,
|
||||
CustomerArchive seller, String salerAddr, String salerBank, String deptNumber, String orgNumber, CustomerArchive customer,
|
||||
CustomerArchive seller, String salerAddr, String salerBank, String deptNumber, String orgNumber, String receiverNumber,
|
||||
String firstArSrcCode, BigDecimal sheetAmount, List<BfiInvoiceApplySaveEntryDTO> items) {
|
||||
BfiInvoiceApplySaveDTO param = new BfiInvoiceApplySaveDTO();
|
||||
// ==================== 以下为【必填】字段(BfiInvoiceApplySaveDTO 标注),非必填字段先注释保留 ====================
|
||||
@@ -965,8 +970,8 @@ public class InvoiceApplicationServiceImpl extends BaseServiceImpl<InvoiceApplic
|
||||
entity.getApplicationNo());
|
||||
}
|
||||
}
|
||||
// 【必填】客户.编码:受票方客商档案客商编码
|
||||
param.setCustomnameidNumber(customer.getCustomerCode());
|
||||
// 【必填】客户.编码:受票方统一社会信用代码经 A901-1 供应商查询取金蝶客商编码
|
||||
param.setCustomnameidNumber(receiverNumber);
|
||||
// 【必填】项目.项目编码(联调期临时传金蝶测试档案值 999)
|
||||
param.setAwrpProjectNumber(KingdeeBfiConstant.BFI_PROJECT_NUMBER_NONE);
|
||||
// ==================== 以下为非必填字段,先注释保留,联调确认后按需放开 ====================
|
||||
|
||||
+1
-1
@@ -1336,7 +1336,7 @@ public class PaymentApplicationServiceImpl extends BaseServiceImpl<PaymentApplic
|
||||
entry.setEPaymenttypeNumber(TransportBusiConstant.PAYMENT_TYPE_SETTLEMENT.equals(entity.getPaymentType()) ? KingdeeBfiConstant.BFI_PAYMENT_TYPE_FORMAL : KingdeeBfiConstant.BFI_PAYMENT_TYPE_PREPAY);
|
||||
// 【必填】往来类型
|
||||
entry.setEAsstacttype(kingdeeApBillSyncSupport.bfiAsstactType(contract));
|
||||
// 【必填】往来户.编码:合同乙方关联客商档案客商编码
|
||||
// 【必填】往来户.编码:合同乙方统一社会信用代码经 A901-1 供应商查询取金蝶客商编码
|
||||
entry.setEAsstactNumber(kingdeeApBillSyncSupport.bfiAsstactNumber(contract, context));
|
||||
// 【必填】往来账户:乙方(收款方)银行账号
|
||||
entry.setEAssacct(entity.getBankAccount());
|
||||
|
||||
+27
-5
@@ -39,9 +39,12 @@ import org.springblade.system.pojo.entity.FeeItem;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiApBillQueryDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiApBillSaveDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiApBillSaveEntryDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.dto.BfiSupplierQueryDTO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiApBillVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiBillSaveResultItemVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiBillSaveResultVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiPageVO;
|
||||
import org.springblade.thirdparty.bfi.pojo.vo.BfiSupplierVO;
|
||||
import org.springblade.thirdparty.bfi.service.IBfiService;
|
||||
import org.springblade.thirdparty.bfi.util.BfiUtil;
|
||||
import org.springblade.transport.config.BfiProperties;
|
||||
@@ -1043,25 +1046,44 @@ public class KingdeeApBillSyncSupport {
|
||||
? KingdeeBfiConstant.BFI_CUSTOMER_ASSTACT_TYPE : KingdeeBfiConstant.BFI_SUPPLIER_ASSTACT_TYPE;*/
|
||||
}
|
||||
|
||||
/** 财务应付单往来户.编码:合同乙方关联客商档案取客商编码,未维护时拦截 */
|
||||
/** 财务应付单往来户.编码:合同乙方关联客商档案取统一社会信用代码,经 A901-1 供应商查询取金蝶客商编码,任一环节缺失时拦截 */
|
||||
public String bfiAsstactNumber(ContractManage contract, KingdeeSyncContext context) {
|
||||
if (Func.isBlank(contract.getPartyB())) {
|
||||
throw new ServiceException("推送金蝶财务应付单失败,合同乙方不能为空,请检查合同[" + Func.toStr(contract.getContractNo()) + "]乙方信息");
|
||||
}
|
||||
// 批量同步时按乙方名称缓存客商编码(同批同一乙方只查一次),单笔同步退化为直接查询
|
||||
// 批量同步时按乙方名称缓存金蝶客商编码(同批同一乙方只查一次),单笔同步退化为直接查询
|
||||
String customerCode = context.customerCodeCache().computeIfAbsent(contract.getPartyB(), this::queryCustomerCode);
|
||||
if (Func.isBlank(customerCode)) {
|
||||
throw new ServiceException("推送金蝶财务应付单失败,合同乙方[" + contract.getPartyB() + "]未在客商档案中维护客商编码,请补充后重试");
|
||||
throw new ServiceException("推送金蝶财务应付单失败,合同乙方[" + contract.getPartyB()
|
||||
+ "]未在客商档案中维护统一社会信用代码或金蝶侧未查到对应供应商档案,请补充后重试");
|
||||
}
|
||||
return customerCode;
|
||||
}
|
||||
|
||||
/** 按乙方名称(全称或简称)查询客商编码,未维护返回 null(应收单同步组件复用:按结算单付款方查询) */
|
||||
/**
|
||||
* 按乙方名称(全称或简称)查客商档案取统一社会信用代码,再经 A901-1 供应商查询取金蝶客商编码(返回值 number),
|
||||
* 任一环节缺失返回 null(应收单同步组件复用:按结算单付款方查询)
|
||||
*/
|
||||
public String queryCustomerCode(String partyB) {
|
||||
CustomerArchive customer = customerArchiveMapper.selectOne(Wrappers.<CustomerArchive>lambdaQuery()
|
||||
.and(wrapper -> wrapper.eq(CustomerArchive::getFullName, partyB).or().eq(CustomerArchive::getShortName, partyB))
|
||||
.eq(CustomerArchive::getIsDeleted, 0).last("limit 1"));
|
||||
return customer == null ? null : customer.getCustomerCode();
|
||||
if (customer == null || Func.isBlank(customer.getUnifiedCreditCode())) {
|
||||
return null;
|
||||
}
|
||||
return this.queryKingdeeSupplierNumber(customer.getUnifiedCreditCode().trim());
|
||||
}
|
||||
|
||||
/** A901-1 按统一社会信用代码查询金蝶供应商档案,取返回值 number 即金蝶客商编码,无数据返回 null(开票申请受票方复用);
|
||||
* shortcut: 查询未过滤 status=C(已审核)/enable=1,暂存/禁用档案的 number 也会返回,金蝶侧拒收时再补过滤 */
|
||||
public String queryKingdeeSupplierNumber(String unifiedCreditCode) {
|
||||
BfiSupplierQueryDTO param = new BfiSupplierQueryDTO();
|
||||
param.setPageNo(1);
|
||||
param.setPageSize(1);
|
||||
param.setSocietycreditcode(List.of(unifiedCreditCode));
|
||||
BfiPageVO<BfiSupplierVO> page = bfiService.querySupplier(param);
|
||||
List<BfiSupplierVO> rows = page == null ? null : page.getRows();
|
||||
return rows == null || rows.isEmpty() ? null : rows.get(0).getNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-2
@@ -202,14 +202,15 @@ public class KingdeeArBillSyncSupport {
|
||||
String currency = kingdeeApBillSyncSupport.bfiCurrency(contract);
|
||||
// 单据日期:yyyy-MM-dd HH:mm:ss(各接口统一格式),以同步当日作为应收单据日期
|
||||
String billDateText = kingdeeApBillSyncSupport.bfiDateTimeText(LocalDate.now());
|
||||
// 往来户.编码:应收结算单付款方(客户)关联客商档案客商编码
|
||||
// 往来户.编码:应收结算单付款方(客户)关联客商档案取统一社会信用代码,经 A901-1 供应商查询取金蝶客商编码
|
||||
String payerName = settlement.getPayerName();
|
||||
if (Func.isBlank(payerName)) {
|
||||
throw new ServiceException("推送金蝶财务应收单失败,结算单付款方不能为空,请检查正式结算单[" + Func.toStr(subject) + "]付款方信息");
|
||||
}
|
||||
String customerCode = context.customerCodeCache().computeIfAbsent(payerName.trim(), kingdeeApBillSyncSupport::queryCustomerCode);
|
||||
if (Func.isBlank(customerCode)) {
|
||||
throw new ServiceException("推送金蝶财务应收单失败,结算单付款方[" + payerName + "]未在客商档案中维护客商编码,请补充后重试");
|
||||
throw new ServiceException("推送金蝶财务应收单失败,结算单付款方[" + payerName
|
||||
+ "]未在客商档案中维护统一社会信用代码或金蝶侧未查到对应供应商档案,请补充后重试");
|
||||
}
|
||||
BfiArBillSaveDTO param = new BfiArBillSaveDTO();
|
||||
// 【必填】单据类型.编码
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ public class KingdeeReceivedInvoiceSyncSupport {
|
||||
param.setOrgNumber(kingdeeApBillSyncSupport.bfiOrgNumber(contract, context));
|
||||
// 【必填】结算币别:合同结算币种
|
||||
param.setCurrencyNumber(kingdeeApBillSyncSupport.bfiCurrency(contract));
|
||||
// 【必填】往来户.编码:合同乙方(开票供应商)客商编码
|
||||
// 【必填】往来户.编码:合同乙方(开票供应商)统一社会信用代码经 A901-1 供应商查询取金蝶客商编码
|
||||
param.setReceivablessuppNumber(kingdeeApBillSyncSupport.bfiAsstactNumber(contract, context));
|
||||
// 【必填】汇率表.编码
|
||||
param.setExratetableNumber(BfiConstant.EXRATE_TABLE_DEFAULT);
|
||||
|
||||
Reference in New Issue
Block a user