发票名校验

This commit is contained in:
程小伟 2025-04-24 14:20:01 +08:00
parent 8d13c5bf87
commit cb2390bcad
2 changed files with 16 additions and 15 deletions

View File

@ -55,22 +55,22 @@ public class CustomInvoiceCloudImportListPlugin extends InvoiceCloudImportListPl
protected void xhSelectInvoiceCallBack(Object returnData) {
Map<String, Object> data = (Map)returnData;
log.info("获取发票助手返回的数据"+data);
log.info("CustomInvoiceCloudImportListPlugin:获取发票助手返回的数据"+data);
DynamicObject org = (DynamicObject)data.get("org");
if (org != null) {
long currUserId = RequestContext.get().getCurrUserId();//获取当前用户ID
log.info("获取当前用户ID");
log.info("CustomInvoiceCloudImportListPlugin:获取当前用户ID");
Object selectInvoice = data.get("selectInvoice");
log.info("获取发票对象"+selectInvoice);
log.info("将selectInvoice解析为发票列表");
log.info("CustomInvoiceCloudImportListPlugin:获取发票对象"+selectInvoice);
log.info("CustomInvoiceCloudImportListPlugin:将selectInvoice解析为发票列表");
//将selectInvoice解析为发票列表
List<InvoiceVO> invoiceVOList = InvoiceDataHandleHelper.parseXhInvoiceCloudReturnData(selectInvoice);
ListShowParameter listShowParameter = (ListShowParameter)this.getView().getFormShowParameter();//获取表单显示参数
log.info("获取表单显示参数");
log.info("CustomInvoiceCloudImportListPlugin:获取表单显示参数");
String billFormId = listShowParameter.getBillFormId();//获取发票ID
log.info("获取发票ID:"+billFormId);
log.info("CustomInvoiceCloudImportListPlugin:获取发票ID:"+billFormId);
//处理发票列表返回mapture对应值表示Set 包含新生成的发票对象false对应Set 包含已存在的发票对象
log.info("处理发票列表返回mapture对应值表示Set 包含新生成的发票对象false对应Set 包含已存在的发票对象。");
log.info("CustomInvoiceCloudImportListPlugin:处理发票列表返回mapture对应值表示Set 包含新生成的发票对象false对应Set 包含已存在的发票对象。");
Map<Boolean, Set<DynamicObject>> invoiceMap = CustomInvoiceDataHandleHelper.processInvoiceVO(invoiceVOList, currUserId, org.getLong("id"), new Date(), billFormId, this.getCurrency(), true);
if (invoiceMap.isEmpty()) {
this.getView().showTipNotification(ResManager.loadKDString("导入发票为空。", "InvoiceCloudImportListPlugin_4", "ec-ecpf-formplugin", new Object[0]));
@ -78,7 +78,7 @@ public class CustomInvoiceCloudImportListPlugin extends InvoiceCloudImportListPl
Set<DynamicObject> newInvoices = (Set)invoiceMap.getOrDefault(Boolean.TRUE, new HashSet(0));//新生成的发票对象
Set<DynamicObject> updateInvoices = (Set)invoiceMap.getOrDefault(Boolean.FALSE, new HashSet(0));//已存在的发票对象
this.saveInvoiceAndGiveTips(newInvoices, updateInvoices, true);//保存发票数据并给出相应的提示
log.info("保存发票数据并给出相应的提示");
log.info("CustomInvoiceCloudImportListPlugin:保存并给出提示");
}
}

View File

@ -60,6 +60,7 @@ public class CustomInvoiceDataHandleHelper extends InvoiceDataHandleHelper {
private CustomInvoiceDataHandleHelper() {}
public static Map<Boolean, Set<DynamicObject>> processInvoiceVO(List<InvoiceVO> list, long userID, long orgID, Date date, String invoiceFormId, DynamicObject currency) {
return processInvoiceVO(list, userID, orgID, date, invoiceFormId, currency, false);
}
@ -107,15 +108,15 @@ public class CustomInvoiceDataHandleHelper extends InvoiceDataHandleHelper {
public static DynamicObject generateInvoiceByVO(InvoiceVO invoiceVO, MainEntityType dt, long id, long userID, long orgID, Date date, DynamicObject currency) {
DynamicObject invoice = new DynamicObject(dt);
invoice.set("id", id);//设置发票的唯一 ID
log.info("设置发票的唯一 ID:"+id);
log.info("CustomInvoiceCloudImportListPlugin:设置发票的唯一 ID:"+id);
invoice.set("serialno", invoiceVO.getSerialNo());//设置发票序列号
log.info("设置发票序列号 serialno:"+invoiceVO.getSerialNo());
log.info("CustomInvoiceCloudImportListPlugin:设置发票序列号 serialno:"+invoiceVO.getSerialNo());
InvoiceTypeEnum invoiceTypeEnum = InvoiceTypeEnum.getEnumByValue(invoiceVO.getInvoiceType());
if (invoiceTypeEnum != null) {
QFilter invoiceTypeFilter = new QFilter("name", "=", invoiceTypeEnum.getName());
DynamicObject invoiceType = BusinessDataServiceHelper.loadSingle("ec_invoice_type", "id", new QFilter[]{invoiceTypeFilter});
invoice.set("invoicetypeid", invoiceType);//设置发票类型
log.info("设置发票类型:"+invoiceType);
log.info("CustomInvoiceCloudImportListPlugin:设置发票类型:"+invoiceType);
}
invoice.set("invoicecode", invoiceVO.getInvoiceCode());//设置发票代码
@ -126,10 +127,10 @@ public class CustomInvoiceDataHandleHelper extends InvoiceDataHandleHelper {
Date invoiceDate = format.parse(invoiceVO.getInvoiceDate());
invoice.set("invoicedate", invoiceDate);//设置发票日期
} catch (ParseException var32) {
log.info("parse invoice date error.");
log.info("CustomInvoiceCloudImportListPlugin:parse invoice date error.");
}
//设置发票的货币类型和各种金额字段
log.info("设置发票的货币类型和各种金额字段");
log.info("CustomInvoiceCloudImportListPlugin:设置发票的货币类型和各种金额字段");
invoice.set("currency", currency);//设置币别
invoice.set("totaloftaxamount", invoiceVO.getTotalAmount());
invoice.set("unapplyamount", invoiceVO.getTotalAmount());
@ -137,7 +138,7 @@ public class CustomInvoiceDataHandleHelper extends InvoiceDataHandleHelper {
invoice.set("unapplyinvtax", invoiceVO.getTaxAmount());
invoice.set("totalamount", invoiceVO.getAmount());
//设置购买方的税务编号银行信息账号电话和地址
log.info("设置购买方的税务编号、银行信息、账号、电话和地址");
log.info("CustomInvoiceCloudImportListPlugin:设置购买方的税务编号、银行信息、账号、电话和地址");
invoice.set("buyertaxno", invoiceVO.getBuyerTaxNo());
invoice.set("buyerbank", TextHelper.getBankName(invoiceVO.getBuyerAccount()));
invoice.set("buyeraccount", TextHelper.getBankNum(invoiceVO.getBuyerAccount()));
@ -150,7 +151,7 @@ public class CustomInvoiceDataHandleHelper extends InvoiceDataHandleHelper {
invoice.set("source", "03");
invoice.set("buyername", invoiceVO.getBuyerName());
//如果是进项发票从业务单元中检索买方信息name 不是就从顾客中检索
log.info("发票名:"+dt.getName());
log.info("CustomInvoiceCloudImportListPlugin:发票名:"+dt.getName());
QFilter buyerFilter = new QFilter("ffirmname", "=", invoiceVO.getBuyerName());//原本查询的是name
DynamicObject buyer = StringUtils.equals(dt.getName(), "ec_in_invoice") ? BusinessDataServiceHelper.loadSingle("bos_org", "", new QFilter[]{buyerFilter}) : BusinessDataServiceHelper.loadSingle("bd_customer", "", new QFilter[]{new QFilter("name", "=", invoiceVO.getBuyerName())});
if (buyer == null) {