发票识别税率*

This commit is contained in:
李贵强 2025-05-29 14:55:47 +08:00
parent b554b09adb
commit bed14f6699
2 changed files with 42 additions and 13 deletions

View File

@ -432,16 +432,31 @@ public class ReconPayreqFormPlugin extends AbstractFormPlugin implements BeforeF
if (items != null){ if (items != null){
for (int x = 0; x < items.size(); x++ ){ for (int x = 0; x < items.size(); x++ ){
JSONObject item = items.getJSONObject(x); JSONObject item = items.getJSONObject(x);
if (item != null){ if (item != null) {
DynamicObject invoiceentr = invoiceentrs.addNew(); DynamicObject invoiceentr = invoiceentrs.addNew();
invoiceentr.set("entry_content",item.getString("name"));//项目名称 invoiceentr.set("entry_content", item.getString("name"));//项目名称
invoiceentr.set("entry_qty",item.getString("quantity"));//数量 invoiceentr.set("entry_qty", item.getString("quantity"));//数量
invoiceentr.set("entry_price",item.getString("price"));//单价 invoiceentr.set("entry_price", item.getString("price"));//单价
invoiceentr.set("entry_notaxamt",item.getString("total"));//金额 invoiceentr.set("entry_notaxamt", item.getString("total"));//金额
if (item.containsKey("tax_rate")){
String tax_rate = item.getString("tax_rate"); int value; // 默认值
String substring = tax_rate.substring(0, tax_rate.length() - 1); if (item.containsKey("tax_rate")) { // 先检查 key 是否存在
int value = Integer.parseInt(substring); try {
String taxRate = item.getString("tax_rate"); // 直接获取
String numericPart;
if (taxRate.contains("*")) {
numericPart = "0";
} else if (taxRate.endsWith("%")) {
numericPart = taxRate.substring(0, taxRate.length() - 1);
} else {
numericPart = taxRate;
}
value = Integer.parseInt(numericPart);
} catch (Exception e) {
// 捕获 JSONException NumberFormatException
value = 0;
}
QFilter bd_taxrate_qf = new QFilter("taxrate",QCP.equals,value); QFilter bd_taxrate_qf = new QFilter("taxrate",QCP.equals,value);
DynamicObject bd_taxrate = BusinessDataServiceHelper.loadSingle("bd_taxrate", bd_taxrate_qf.toArray()); DynamicObject bd_taxrate = BusinessDataServiceHelper.loadSingle("bd_taxrate", bd_taxrate_qf.toArray());
invoiceentr.set("entry_taxrate",bd_taxrate);//税率 invoiceentr.set("entry_taxrate",bd_taxrate);//税率

View File

@ -400,10 +400,24 @@ public class ReconPayreqNewFormPlugin extends AbstractFormPlugin implements Befo
invoiceentr.set("entry_qty",item.getString("quantity"));//数量 invoiceentr.set("entry_qty",item.getString("quantity"));//数量
invoiceentr.set("entry_price",item.getString("price"));//单价 invoiceentr.set("entry_price",item.getString("price"));//单价
invoiceentr.set("entry_notaxamt",item.getString("total"));//金额 invoiceentr.set("entry_notaxamt",item.getString("total"));//金额
if (item.containsKey("tax_rate")){ int value; // 默认值
String tax_rate = item.getString("tax_rate"); if (item.containsKey("tax_rate")) { // 先检查 key 是否存在
String substring = tax_rate.substring(0, tax_rate.length() - 1); try {
int value = Integer.parseInt(substring); String taxRate = item.getString("tax_rate"); // 直接获取
String numericPart;
if (taxRate.contains("*")) {
numericPart = "0";
} else if (taxRate.endsWith("%")) {
numericPart = taxRate.substring(0, taxRate.length() - 1);
} else {
numericPart = taxRate;
}
value = Integer.parseInt(numericPart);
} catch (Exception e) {
// 捕获 JSONException NumberFormatException
value = 0;
}
QFilter bd_taxrate_qf = new QFilter("taxrate",QCP.equals,value); QFilter bd_taxrate_qf = new QFilter("taxrate",QCP.equals,value);
DynamicObject bd_taxrate = BusinessDataServiceHelper.loadSingle("bd_taxrate", bd_taxrate_qf.toArray()); DynamicObject bd_taxrate = BusinessDataServiceHelper.loadSingle("bd_taxrate", bd_taxrate_qf.toArray());
invoiceentr.set("entry_taxrate",bd_taxrate);//税率 invoiceentr.set("entry_taxrate",bd_taxrate);//税率