|
|
|
@ -540,52 +540,54 @@ public class BaseInvoiceManualCheckServiceImpl extends MpBaseServiceImpl<BaseTDx |
|
|
|
|
currentTax = currentTax.subtract(pageList.get(i).getTaxAmount()); |
|
|
|
|
hjje = hjje.subtract(pageList.get(i).getInvoiceAmount()); |
|
|
|
|
|
|
|
|
|
List<BaseTDxRecordInvoice> collect = pageList.stream().skip(i + 1).sorted(Comparator.comparing(BaseTDxRecordInvoice::getTaxAmount)).collect(Collectors.toList()); |
|
|
|
|
log.info("collect====>{}",collect); |
|
|
|
|
if (collect != null && collect.size() > 0){ |
|
|
|
|
log.info("从小到大排序在进行添加"); |
|
|
|
|
for (int j = 0; j < collect.size(); j++) { |
|
|
|
|
if (collect.get(j).getTaxAmount().compareTo(new BigDecimal("0"))<1){ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
currentTax = currentTax.add(collect.get(j).getTaxAmount()); |
|
|
|
|
hjje = hjje.add(collect.get(j).getInvoiceAmount()); |
|
|
|
|
log.info("maxTax====>"+maxTax+",currentTax====>"+currentTax); |
|
|
|
|
if (maxTax.compareTo(currentTax)>0){ |
|
|
|
|
count++; |
|
|
|
|
log.info("最小排序count++{}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje); |
|
|
|
|
|
|
|
|
|
//发票状态不能认证
|
|
|
|
|
String invoiceStatus="07"; |
|
|
|
|
if ( pageList.get(i).getInvoiceStatus() != null && !invoiceStatus.contains(pageList.get(i).getInvoiceStatus()) |
|
|
|
|
|| pageList.get(i).getInvoiceAmount() != null && pageList.get(i).getInvoiceAmount().compareTo(new BigDecimal(0)) < 0 |
|
|
|
|
|| pageList.get(i).getTaxAmount() != null && pageList.get(i).getTaxAmount().compareTo(new BigDecimal(0)) < 0) { |
|
|
|
|
|
|
|
|
|
currentTax = currentTax.subtract(pageList.get(i).getTaxAmount()); |
|
|
|
|
hjje = hjje.subtract(pageList.get(i).getInvoiceAmount()); |
|
|
|
|
count--; |
|
|
|
|
log.info("最小排序count--{}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje); |
|
|
|
|
if (i<pageList.size()-1){ |
|
|
|
|
List<BaseTDxRecordInvoice> collect = pageList.stream().skip(i + 1).sorted(Comparator.comparing(BaseTDxRecordInvoice::getTaxAmount)).collect(Collectors.toList()); |
|
|
|
|
log.info("collect====>{}",collect); |
|
|
|
|
if (collect != null && collect.size() > 0){ |
|
|
|
|
log.info("从小到大排序在进行添加"); |
|
|
|
|
for (int j = 0; j < collect.size(); j++) { |
|
|
|
|
if (collect.get(j).getTaxAmount().compareTo(new BigDecimal("0"))<1){ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
//发票税号一申请抵扣统计
|
|
|
|
|
if (!gfshList1.contains(pageList.get(i).getGfTaxNo())) { |
|
|
|
|
//该发票税号已申请抵扣统计
|
|
|
|
|
currentTax = currentTax.add(collect.get(j).getTaxAmount()); |
|
|
|
|
hjje = hjje.add(collect.get(j).getInvoiceAmount()); |
|
|
|
|
log.info("maxTax====>"+maxTax+",currentTax====>"+currentTax); |
|
|
|
|
if (maxTax.compareTo(currentTax)>0){ |
|
|
|
|
count++; |
|
|
|
|
log.info("最小排序count++{}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje); |
|
|
|
|
|
|
|
|
|
//发票状态不能认证
|
|
|
|
|
String invoiceStatus="07"; |
|
|
|
|
if ( pageList.get(i).getInvoiceStatus() != null && !invoiceStatus.contains(pageList.get(i).getInvoiceStatus()) |
|
|
|
|
|| pageList.get(i).getInvoiceAmount() != null && pageList.get(i).getInvoiceAmount().compareTo(new BigDecimal(0)) < 0 |
|
|
|
|
|| pageList.get(i).getTaxAmount() != null && pageList.get(i).getTaxAmount().compareTo(new BigDecimal(0)) < 0) { |
|
|
|
|
|
|
|
|
|
currentTax = currentTax.subtract(pageList.get(i).getTaxAmount()); |
|
|
|
|
hjje = hjje.subtract(pageList.get(i).getInvoiceAmount()); |
|
|
|
|
count--; |
|
|
|
|
log.info("最小排序count--{}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
//发票税号一申请抵扣统计
|
|
|
|
|
if (!gfshList1.contains(pageList.get(i).getGfTaxNo())) { |
|
|
|
|
//该发票税号已申请抵扣统计
|
|
|
|
|
currentTax = currentTax.subtract(pageList.get(i).getTaxAmount()); |
|
|
|
|
hjje = hjje.subtract(pageList.get(i).getInvoiceAmount()); |
|
|
|
|
count--; |
|
|
|
|
log.info("最小排序已申请抵扣统计 count-- ==={}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje); |
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BaseSggxCxRespVO vo = getBaseSggxCxRespVO(collect.get(j), count, taxnoList, businessList); |
|
|
|
|
log.info("returnList添加vo"); |
|
|
|
|
returnList.add(vo); |
|
|
|
|
}else { |
|
|
|
|
log.info("最小排序统计税额超出税额上限减去最后一个,并结束循环遍历"); |
|
|
|
|
currentTax = currentTax.subtract(pageList.get(i).getTaxAmount()); |
|
|
|
|
hjje = hjje.subtract(pageList.get(i).getInvoiceAmount()); |
|
|
|
|
count--; |
|
|
|
|
log.info("最小排序已申请抵扣统计 count-- ==={}"+count+",currentTax==》"+currentTax+",hjje===>"+hjje); |
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
BaseSggxCxRespVO vo = getBaseSggxCxRespVO(collect.get(j), count, taxnoList, businessList); |
|
|
|
|
log.info("returnList添加vo"); |
|
|
|
|
returnList.add(vo); |
|
|
|
|
}else { |
|
|
|
|
log.info("最小排序统计税额超出税额上限减去最后一个,并结束循环遍历"); |
|
|
|
|
currentTax = currentTax.subtract(pageList.get(i).getTaxAmount()); |
|
|
|
|
hjje = hjje.subtract(pageList.get(i).getInvoiceAmount()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|