|
|
|
@ -128,9 +128,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
|
|
|
|
|
QueryWrapper<BaseTDxRecordInvoice> recordWrapper = new QueryWrapper<>(); |
|
|
|
|
String uuid = ""; |
|
|
|
|
if(StringUtils.isNoneBlank(fpdm)){ |
|
|
|
|
if (StringUtils.isNoneBlank(fpdm)) { |
|
|
|
|
uuid = fpdm + fphm; |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
uuid = fpdm; |
|
|
|
|
} |
|
|
|
|
recordWrapper.eq("uuid", uuid); |
|
|
|
@ -157,7 +157,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
recordInvoice.setInvoiceCode(fpdm); |
|
|
|
|
recordInvoice.setInvoiceNo(fphm); |
|
|
|
|
recordInvoice.setInvoiceAmount(new BigDecimal(je)); |
|
|
|
|
if(se != null) { |
|
|
|
|
recordInvoice.setTaxAmount(new BigDecimal(se)); |
|
|
|
|
} |
|
|
|
|
recordInvoice.setXfTaxNo(xfsh); |
|
|
|
|
recordInvoice.setGfTaxNo(gfsbh); |
|
|
|
|
recordInvoice.setGfName(gfmc); |
|
|
|
@ -504,15 +506,17 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
int index = taxRateDetail.indexOf("%"); |
|
|
|
|
if (index > 0) { |
|
|
|
|
taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); |
|
|
|
|
int num = Integer.parseInt(taxRateDetail); |
|
|
|
|
Float num = Float.parseFloat(taxRateDetail); |
|
|
|
|
if (num > 9) { |
|
|
|
|
taxRateDetail = "0." + taxRateDetail; |
|
|
|
|
} else { |
|
|
|
|
if(!taxRateDetail.startsWith("0")){ |
|
|
|
|
taxRateDetail = "0.0" + taxRateDetail; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
taxRateDetail = "0.000"; |
|
|
|
@ -549,74 +553,88 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
return jsonObject; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public TDxInvoiceReimburse updateInvoicePoll(@RequestBody SNRequestObject snRequestObject, String company, String taxNo, TDxInvoiceReimburse reimburse, SNInvoice invoice, String fplxdm, String invoiceCode, String invoiceNo) throws Exception { |
|
|
|
|
public String updateInvoicePoll(@RequestBody SNRequestObject snRequestObject, String company, String taxNo, TDxInvoiceReimburse reimburse, SNInvoice invoice, String fplxdm, String invoiceCode, String invoiceNo) throws Exception { |
|
|
|
|
String result = "0000"; |
|
|
|
|
|
|
|
|
|
//判断发票类型
|
|
|
|
|
fplxdm = getFplx(invoice, fplxdm); |
|
|
|
|
|
|
|
|
|
//如果是可价税分离的票种,直接入报销库
|
|
|
|
|
if(SNFplxEnum.HCP.getFplxDm().equals(fplxdm) || SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm) |
|
|
|
|
if (SNFplxEnum.HCP.getFplxDm().equals(fplxdm) || SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm) |
|
|
|
|
|| SNFplxEnum.JPXCD.getFplxDm().equals(fplxdm) || SNFplxEnum.CP.getFplxDm().equals(fplxdm) |
|
|
|
|
|| SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)){ |
|
|
|
|
|| SNFplxEnum.KYQCP.getFplxDm().equals(fplxdm)) { |
|
|
|
|
InvoiceInfo invoiceInfo = convertToInvoiceInfo(invoice); |
|
|
|
|
log.info("进行价税分离的发票信息为:{}", invoiceInfo); |
|
|
|
|
|
|
|
|
|
ServiceResult<InvoiceInfo> invoiceResult = this.valoremTaxCount(invoiceInfo, "Y"); |
|
|
|
|
InvoiceInfo data = invoiceResult.getData(); |
|
|
|
|
|
|
|
|
|
if (data != null) { |
|
|
|
|
invoice.setIsDeductible(data.getIsDeductible()); |
|
|
|
|
invoice.setTaxRate(data.getTaxRate()); |
|
|
|
|
if(data.getInvoiceAmount() != null) { |
|
|
|
|
invoice.setTotalAmount(data.getInvoiceAmount().toString()); |
|
|
|
|
} |
|
|
|
|
if(data.getTaxAmount() != null) { |
|
|
|
|
invoice.setTotalTax(data.getTaxAmount().toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!"ok".equals(invoiceResult.getMsg()) && !"0000".equals(invoiceResult.getMsg())) { |
|
|
|
|
log.info("价税分离失败:{}",invoiceResult.getMsg()); |
|
|
|
|
return invoiceResult.getMsg(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reimburse = convertToReimburse(invoice,reimburse,fplxdm,company); |
|
|
|
|
reimburse = convertToReimburse(invoice, reimburse, fplxdm, company); |
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
int insert = 0; |
|
|
|
|
QueryWrapper wrapper = new QueryWrapper(); |
|
|
|
|
wrapper.eq("uuid",reimburse.getUuid()); |
|
|
|
|
wrapper.eq("uuid", reimburse.getUuid()); |
|
|
|
|
TDxInvoiceReimburse reimburse1 = tDxInvoiceReimburseService.getBaseMapper().selectOne(wrapper); |
|
|
|
|
if(reimburse1 != null){ |
|
|
|
|
if (reimburse1 != null) { |
|
|
|
|
insert = tDxInvoiceReimburseService.getBaseMapper().updateById(reimburse1); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
insert = tDxInvoiceReimburseService.getBaseMapper().insert(reimburse); |
|
|
|
|
} |
|
|
|
|
if(insert > 0){ |
|
|
|
|
if (insert > 0) { |
|
|
|
|
log.info("实名客票插入报销库成功"); |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
//如果是可查验类型,直接更新数据库
|
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(invoiceCode,invoiceNo); |
|
|
|
|
InvoiceUtil iu = new InvoiceUtil(invoiceCode, invoiceNo); |
|
|
|
|
fplxdm = iu.getFplxdm(); |
|
|
|
|
|
|
|
|
|
if(fplxdm != null) { |
|
|
|
|
if (fplxdm != null) { |
|
|
|
|
//可查验发票,已入库,更新票池
|
|
|
|
|
Integer integer = this.pushInvoiceToRecordInvoice2(snRequestObject); |
|
|
|
|
log.info("可查验发票,更新票池完成"); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
//不可查验发票,未入库,插入票池
|
|
|
|
|
this.pushInvoiceToRecordInvoice(snRequestObject,taxNo,company); |
|
|
|
|
this.pushInvoiceToRecordInvoice(snRequestObject, taxNo, company); |
|
|
|
|
log.info("不可查验发票,更新票池完成"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return reimburse; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private TDxInvoiceReimburse convertToReimburse(SNInvoice invoice, TDxInvoiceReimburse reimburse,String fplxdm,String company) { |
|
|
|
|
private TDxInvoiceReimburse convertToReimburse(SNInvoice invoice, TDxInvoiceReimburse reimburse, String fplxdm, String company) { |
|
|
|
|
|
|
|
|
|
reimburse.setInvoiceType(fplxdm); |
|
|
|
|
reimburse.setInvoiceCode(invoice.getInvoiceCode()); |
|
|
|
|
reimburse.setInvoiceNo(invoice.getInvoiceNumber()); |
|
|
|
|
reimburse.setInvoiceDate(invoice.getBillingDate()); |
|
|
|
|
reimburse.setPassenger(invoice.getRiderName()); |
|
|
|
|
if(invoice.getTotalAmount() != null) { |
|
|
|
|
if (invoice.getTotalAmount() != null) { |
|
|
|
|
reimburse.setInvoiceAmount(new BigDecimal(invoice.getTotalAmount())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(invoice.getAmountTax() != null) { |
|
|
|
|
if (invoice.getAmountTax() != null) { |
|
|
|
|
reimburse.setTotalAmount(new BigDecimal(invoice.getAmountTax())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(invoice.getTotalTax() != null) { |
|
|
|
|
if (invoice.getTotalTax() != null) { |
|
|
|
|
reimburse.setTaxAmount(new BigDecimal(invoice.getTotalTax())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -638,9 +656,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
reimburse.setTaxRate(invoice.getTaxRate()); |
|
|
|
|
reimburse.setIsDeduction(invoice.getIsDeductible()); |
|
|
|
|
|
|
|
|
|
if(StringUtils.isNoneBlank(reimburse.getInvoiceCode())){ |
|
|
|
|
if (StringUtils.isNoneBlank(reimburse.getInvoiceCode())) { |
|
|
|
|
reimburse.setUuid(reimburse.getInvoiceCode() + reimburse.getInvoiceNo()); |
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
reimburse.setUuid(reimburse.getInvoiceNo()); |
|
|
|
|
} |
|
|
|
|
Date date = new Date(); |
|
|
|
@ -677,15 +695,15 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
invoice.setPassenger(snInvoice.getRiderName()); |
|
|
|
|
invoice.setDepartCity(snInvoice.getStationGetOn()); |
|
|
|
|
invoice.setArriveCity(snInvoice.getStationGetOff()); |
|
|
|
|
if("92".equals(invoice.getInvoiceTypeCode())){ |
|
|
|
|
if(snInvoice.getAmountTax() != null) |
|
|
|
|
if ("92".equals(invoice.getInvoiceTypeCode())) { |
|
|
|
|
if (snInvoice.getAmountTax() != null) |
|
|
|
|
invoice.setInvoiceAmount(new BigDecimal(snInvoice.getAmountTax())); |
|
|
|
|
} |
|
|
|
|
if("90".equals(invoice.getInvoiceTypeCode())) { |
|
|
|
|
if ("90".equals(invoice.getInvoiceTypeCode())) { |
|
|
|
|
invoice.setFare(snInvoice.getNoTaxAmount()); |
|
|
|
|
invoice.setFuelSurcharge(snInvoice.getFuelSurcharge()); |
|
|
|
|
} |
|
|
|
|
if(snInvoice.getNoTaxAmount() != null){ |
|
|
|
|
if (snInvoice.getNoTaxAmount() != null) { |
|
|
|
|
BigDecimal amount = new BigDecimal(snInvoice.getNoTaxAmount()); |
|
|
|
|
invoice.setInvoiceAmount(amount); |
|
|
|
|
} |
|
|
|
@ -696,47 +714,47 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
private String getFplx(SNInvoice invoice, String fplxdm) { |
|
|
|
|
String snFplx = invoice.getInvoiceType(); |
|
|
|
|
|
|
|
|
|
if(SNFplxEnum.HCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.HCP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "92"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.KYQCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.KYQCP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "94"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.JPXCD.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.JPXCD.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "90"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.DEFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.DEFP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "95"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.JDFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.JDFP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "97"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.CZCFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.CZCFP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "91"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.KYQCP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.KYQCP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "89"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.GLF.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.GLF.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "101"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.CP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.CP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "88"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.GJXP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.GJXP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "99"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
|
if(SNFplxEnum.QTFP.getSnFplxDm().equals(snFplx)){ |
|
|
|
|
if (SNFplxEnum.QTFP.getSnFplxDm().equals(snFplx)) { |
|
|
|
|
fplxdm = "00"; |
|
|
|
|
invoice.setInvoiceType(fplxdm); |
|
|
|
|
} |
|
|
|
@ -768,11 +786,11 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验客票可抵扣条件
|
|
|
|
|
ServiceResult<?> result = checkIsDeduction(invoiceInfo); |
|
|
|
|
if (!result.getResult()) { |
|
|
|
|
logger.error("客票价税计算失败:" + result.getMsg()); |
|
|
|
|
return fail(result.getMsg()); |
|
|
|
|
} |
|
|
|
|
// ServiceResult<?> result = checkIsDeduction(invoiceInfo);
|
|
|
|
|
// if (!result.getResult()) {
|
|
|
|
|
// logger.error("客票价税计算失败:" + result.getMsg());
|
|
|
|
|
// return fail(result.getMsg());
|
|
|
|
|
// }
|
|
|
|
|
// 设置可抵扣标识
|
|
|
|
|
invoiceInfo.setIsDeductible(isDeductible); |
|
|
|
|
// 设置税率
|
|
|
|
@ -802,11 +820,13 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
|
} |
|
|
|
|
// 铁路客票:税额=票面金额÷(1+9%)×9%
|
|
|
|
|
} else if (invoiceInfo.getInvoiceTypeCode().equals(Constant.RAILWAY_TICKET_CODE)) { |
|
|
|
|
if (invoiceInfo.getInvoiceAmount() != null) |
|
|
|
|
invoiceInfo.setTaxAmount(invoiceInfo.getInvoiceAmount() |
|
|
|
|
.divide(new BigDecimal("1.09"), 6, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("0.09"))); |
|
|
|
|
// 公路、水路、其他客票:税额=票面金额÷(1+3%)×3%
|
|
|
|
|
} else if (!invoiceInfo.getInvoiceTypeCode().equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE) |
|
|
|
|
&& !invoiceInfo.getInvoiceTypeCode().equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE)) { |
|
|
|
|
if (invoiceInfo.getInvoiceAmount() != null) |
|
|
|
|
invoiceInfo.setInvoiceAmount(invoiceInfo.getInvoiceAmount() |
|
|
|
|
.divide(new BigDecimal("1.03"), 6, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("0.03"))); |
|
|
|
|
} |
|
|
|
|