diff --git a/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java b/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java index 3d5d8e1..05b5549 100644 --- a/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java +++ b/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java @@ -660,10 +660,7 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen BigDecimal commonTaxRate = null; Long commonTaxRateId = null; boolean hasDifferentTaxRates = false; - //本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率) - BigDecimal entryNotTaxAmount; - //本次核销金额的税额=含税金额(本次核销金额) - 本次核销不含税金额 - //BigDecimal entryTaxAmount = BigDecimal.ZERO; + // 遍历发票 for (DynamicObject invoiceObj : invoiceEntry) { @@ -680,10 +677,6 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen if (invoice != null) { String invoiceName = invoice.getString("name"); if (invoiceName != null && invoiceName.contains("专用")) { - - taxAmount = taxAmount.add(hasWriteOffAmt); - - // 发票登记-发票明细————————只有一行 DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry"); if (invoiceDetails != null && invoiceDetails.size() != 0) { @@ -693,11 +686,13 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen Long currentTaxRateId = (Long) entryTaxRate.getPkValue(); BigDecimal currentTaxRate = entryTaxRate.getBigDecimal("taxrate"); //本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率) - entryNotTaxAmount=hasWriteOffAmt.divide(currentTaxRate.add(BigDecimal.ONE),2, RoundingMode.HALF_UP); + BigDecimal entryNotTaxAmount=hasWriteOffAmt.divide(currentTaxRate.add(BigDecimal.ONE),2, RoundingMode.HALF_UP); // 专票不含税=本次核销不含税金额累加 // 本次核销不含税金额累加 notTaxAmount=notTaxAmount.add(entryNotTaxAmount); - + //本次核销税额 = 申请核销-本次核销不含税 + BigDecimal entryTaxAmount=hasWriteOffAmt.subtract(entryNotTaxAmount).setScale(2, RoundingMode.HALF_UP); + taxAmount = taxAmount.add(entryTaxAmount); // 第一次遇到税率,记录下来 if (commonTaxRateId == null) { commonTaxRateId = currentTaxRateId; @@ -778,7 +773,7 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen } } else { - // 税额=本次核销税额累加(只针对专票); + // 税额=本次申请核销税额累加(只针对专票); BigDecimal taxAmount = BigDecimal.ZERO; //不含税金额(专普混合:专票本次核销不含税金额累加+普票用本次核销金额进行累加) BigDecimal notTaxAmount = BigDecimal.ZERO; @@ -786,10 +781,6 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen BigDecimal commonTaxRate = null; Long commonTaxRateId = null; boolean hasDifferentTaxRates = false; - //本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率) - BigDecimal entryNotTaxAmount; - //本次核销金额的税额=含税金额(本次核销金额) - 本次核销不含税金额 - //BigDecimal entryTaxAmount = BigDecimal.ZERO; // 遍历发票 for (DynamicObject invoiceObj : invoiceEntry) { @@ -800,16 +791,11 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen if (invoiceBill != null) { //本次核销金额 BigDecimal hasWriteOffAmt = invoiceObj.getBigDecimal("inventry_haswriteoffamt"); - // 判断【发票登记-发票类型-名称】 DynamicObject invoice = invoiceBill.getDynamicObject("invoice"); if (invoice != null) { String invoiceName = invoice.getString("name"); if (invoiceName != null && invoiceName.contains("专用")) { - - taxAmount = taxAmount.add(hasWriteOffAmt); - - // 发票登记-发票明细————————只有一行 DynamicObjectCollection invoiceDetails = invoiceBill.getDynamicObjectCollection("invoiceentry"); if (invoiceDetails != null && invoiceDetails.size() != 0) { @@ -819,11 +805,13 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen Long currentTaxRateId = (Long) entryTaxRate.getPkValue(); BigDecimal currentTaxRate = entryTaxRate.getBigDecimal("taxrate"); //本次核销不含税金额=含税金额(本次核销金额)÷ (1 + 税率) - entryNotTaxAmount=hasWriteOffAmt.divide(currentTaxRate.add(BigDecimal.ONE),2, RoundingMode.HALF_UP); + BigDecimal entryNotTaxAmount=hasWriteOffAmt.divide(currentTaxRate.add(BigDecimal.ONE),2, RoundingMode.HALF_UP); // 专票不含税=本次核销不含税金额累加 // 本次核销不含税金额累加 notTaxAmount=notTaxAmount.add(entryNotTaxAmount); - + //本次核销税额 = 申请核销-本次核销不含税 + BigDecimal entryTaxAmount=hasWriteOffAmt.subtract(entryNotTaxAmount).setScale(2, RoundingMode.HALF_UP); + taxAmount = taxAmount.add(entryTaxAmount); // 第一次遇到税率,记录下来 if (commonTaxRateId == null) { commonTaxRateId = currentTaxRateId;