|
|
@@ -312,8 +312,6 @@ public class InvoiceLibraryServiceImpl extends ServiceImpl<InvoiceLibraryMapper,
|
|
|
// 获取税率,供共享发票使用
|
|
|
Object taxRateObj = invoice.get("taxRate");
|
|
|
Object kind = invoice.getString("kindName");
|
|
|
- System.out.println("qqq"+taxRateObj);
|
|
|
- System.out.println("qqq"+kind);
|
|
|
|
|
|
if (taxRateObj != null) {
|
|
|
String taxRateStr = String.valueOf(taxRateObj);
|
|
|
@@ -3388,8 +3386,30 @@ public class InvoiceLibraryServiceImpl extends ServiceImpl<InvoiceLibraryMapper,
|
|
|
UtilMap.getList(prop, "VatInvoiceItemInfos") != null && !UtilMap.getList(prop, "VatInvoiceItemInfos").isEmpty()
|
|
|
? UtilMap.getList(prop, "VatInvoiceItemInfos")
|
|
|
: UtilMap.getList(prop, "VatElectronicItems");
|
|
|
+// if (!vatInvoiceItemInfos.isEmpty()) {
|
|
|
+// taxRate = UtilMap.getString(vatInvoiceItemInfos.get(0), "TaxRate");
|
|
|
+// }
|
|
|
if (!vatInvoiceItemInfos.isEmpty()) {
|
|
|
- taxRate = UtilMap.getString(vatInvoiceItemInfos.get(0), "TaxRate");
|
|
|
+ String originalTaxRate = UtilMap.getString(vatInvoiceItemInfos.get(0), "TaxRate");
|
|
|
+
|
|
|
+ // 判断是否为有效数字(包括带%号的格式,如"9%")
|
|
|
+ if (StringUtils.isNotBlank(originalTaxRate)) {
|
|
|
+ // 移除百分号并尝试解析为数字
|
|
|
+ String cleanedTaxRate = originalTaxRate.replace("%", "").trim();
|
|
|
+ try {
|
|
|
+ // 尝试转换为数字
|
|
|
+ new BigDecimal(cleanedTaxRate);
|
|
|
+ taxRate = originalTaxRate; // 保持原值(可能带%)
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 如果不是数字(如"不征税"、"免税"等),赋值为"0"
|
|
|
+ taxRate = "0";
|
|
|
+ log.debug("税率格式异常,原始值: {}, 已设置为0", originalTaxRate);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ taxRate = "0";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ taxRate = "0";
|
|
|
}
|
|
|
String no = UtilMap.getString(prop, "Number");
|
|
|
if (nos.contains(no)) {
|