|
|
|
@ -33,7 +33,6 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.math.RoundingMode; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
@ -107,7 +106,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private GatherService gatherService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
@ -268,6 +266,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
log.error("查验失败,errormsg:{}",e.getMessage()); |
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败,"+e.getMessage()))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
|
|
|
|
|
|
if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) { |
|
|
|
@ -290,7 +289,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
|
|
|
|
|
return ResponseEntity.ok(JSONObject.toJSONString(data)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
//其他类发票,直接入库
|
|
|
|
|
log.info("其他类发票,不做查验,直接入库"); |
|
|
|
@ -506,33 +504,24 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
int index = taxRateDetail.indexOf("%"); |
|
|
|
|
if (index > 0) { |
|
|
|
|
taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); |
|
|
|
|
Float num = Float.parseFloat(taxRateDetail); |
|
|
|
|
if (num > 9) { |
|
|
|
|
taxRateDetail = "0." + taxRateDetail; |
|
|
|
|
} else { |
|
|
|
|
if (!taxRateDetail.startsWith("0")) { |
|
|
|
|
taxRateDetail = "0.0" + taxRateDetail; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Float num = Float.parseFloat(taxRateDetail); |
|
|
|
|
if (num > 9) { |
|
|
|
|
taxRateDetail = "0." + taxRateDetail; |
|
|
|
|
} else { |
|
|
|
|
if (!taxRateDetail.startsWith("0")) { |
|
|
|
|
taxRateDetail = "0.0" + taxRateDetail; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Float num = Float.parseFloat(taxRateDetail);
|
|
|
|
|
// if (num > 9) {
|
|
|
|
|
// taxRateDetail = "0." + taxRateDetail;
|
|
|
|
|
// } else {
|
|
|
|
|
// if (!taxRateDetail.startsWith("0")) {
|
|
|
|
|
// taxRateDetail = "0.0" + taxRateDetail;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}catch (Exception e){ |
|
|
|
|
log.error("报错的原因为:{}",e); |
|
|
|
|
taxRateDetail = "0.00"; |
|
|
|
|
taxRateDetail = "0"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ("11".equals(invoiceType)) { |
|
|
|
|
taxRateDetail = "0.000"; |
|
|
|
|
taxRateDetail = "0"; |
|
|
|
|
} |
|
|
|
|
log.info("明细-发票税率为:{}", taxRateDetail); |
|
|
|
|
snDetailMap.put("taxRate", taxRateDetail); |
|
|
|
@ -798,7 +787,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
info.setZGFZH(snInvoice.getPurchaserBank()); |
|
|
|
|
info.setZBZ(snInvoice.getRemarks()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SNInvoiceDetail> invoiceLineList = snInvoice.getInvoiceLineList(); |
|
|
|
|
List<SAPInvoiceDetail> sapInvoiceDetailList = new ArrayList<>(); |
|
|
|
|
//查询明细
|
|
|
|
@ -830,36 +818,26 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount()); |
|
|
|
|
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo()); |
|
|
|
|
//将类似于0.03数据格式转化为3.00
|
|
|
|
|
if (snInvoiceDetail.getTaxRate() != null && !"".equals(snInvoiceDetail.getTaxRate())) { |
|
|
|
|
if (snInvoiceDetail.getTaxRate() != null && snInvoiceDetail.getTaxRate() != "") { |
|
|
|
|
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); |
|
|
|
|
if ("0".equals(snInvoiceDetail.getTaxRate())) { |
|
|
|
|
sapInvoiceDetail.setZTAX("0.00"); |
|
|
|
|
sapInvoiceDetail.setZSM(sapInvoiceDetail.getZTAX()); |
|
|
|
|
// sapInvoiceDetail.setZSM(sapInvoiceDetail.getZTAX());
|
|
|
|
|
} |
|
|
|
|
if (snInvoiceDetail.getTaxRate().contains(".")) { |
|
|
|
|
String getTaxRate = snInvoiceDetail.getTaxRate(); |
|
|
|
|
// if (snInvoiceDetail.getTaxRate().length() > 4) {
|
|
|
|
|
// getTaxRate = getTaxRate.substring(0, 4);
|
|
|
|
|
// }
|
|
|
|
|
if (snInvoiceDetail.getTaxRate().length() > 4) { |
|
|
|
|
getTaxRate = getTaxRate.substring(0, 4); |
|
|
|
|
} |
|
|
|
|
BigDecimal tax = new BigDecimal(getTaxRate); |
|
|
|
|
sapInvoiceDetail.setZSM(getZSM(tax.toString())); |
|
|
|
|
BigDecimal tax1 = tax.multiply(new BigDecimal("100")); |
|
|
|
|
sapInvoiceDetail.setZTAX(tax1.toString()); |
|
|
|
|
if (tax1.compareTo(new BigDecimal("100")) > 0) { |
|
|
|
|
sapInvoiceDetail.setZTAX(snInvoiceDetail.getTaxRate()); |
|
|
|
|
} else if (tax1.scale() > 2) { |
|
|
|
|
BigDecimal substring = tax1.setScale(2, RoundingMode.FLOOR); |
|
|
|
|
sapInvoiceDetail.setZTAX(substring.toPlainString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (snInvoiceDetail.getTaxRate().contains("%") && !snInvoiceDetail.getTaxRate().contains(".")) { |
|
|
|
|
String replace = snInvoiceDetail.getTaxRate().replace("%", ".00"); |
|
|
|
|
String replaceZsm = snInvoiceDetail.getTaxRate().replace("%", ""); |
|
|
|
|
sapInvoiceDetail.setZSM(getZSM(replaceZsm)); |
|
|
|
|
sapInvoiceDetail.setZTAX(replace); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// if (invoiceLineList.size() == 1 && snInvoice.getTaxRate() == null) {
|
|
|
|
|
// info.setZTAX(sapInvoiceDetail.getZTAX());
|
|
|
|
@ -885,16 +863,15 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
sapInvoiceDetail.setZSL(snInvoiceDetail.getQuantity()); |
|
|
|
|
|
|
|
|
|
// String zsmTax = snInvoiceDetail.getTaxRate();
|
|
|
|
|
// if (zsmTax != null && zsmTax != "" && zsmTax.length() > 4) {
|
|
|
|
|
// zsmTax = zsmTax.substring(0, 4);
|
|
|
|
|
// }
|
|
|
|
|
// if (zsmTax != null && zsmTax.contains("%") && !zsmTax.contains(".")) {
|
|
|
|
|
// zsmTax = (new BigDecimal(zsmTax.replace("%", ""))).divide(new BigDecimal("100")).toString();
|
|
|
|
|
// }
|
|
|
|
|
//// sapInvoiceDetail.setZSM(getZSM(snInvoiceDetail.getTaxRate()));
|
|
|
|
|
// sapInvoiceDetail.setZSM(getZSM(zsmTax));
|
|
|
|
|
String zsmTax = snInvoiceDetail.getTaxRate(); |
|
|
|
|
if (zsmTax != null && zsmTax != "" && zsmTax.length() > 4) { |
|
|
|
|
zsmTax = zsmTax.substring(0, 4); |
|
|
|
|
} |
|
|
|
|
if (zsmTax != null && zsmTax.contains("%") && !zsmTax.contains(".")) { |
|
|
|
|
zsmTax = (new BigDecimal(zsmTax.replace("%", ""))).divide(new BigDecimal("100")).toString(); |
|
|
|
|
} |
|
|
|
|
// sapInvoiceDetail.setZSM(getZSM(snInvoiceDetail.getTaxRate()));
|
|
|
|
|
sapInvoiceDetail.setZSM(getZSM(zsmTax)); |
|
|
|
|
sapInvoiceDetail.setZGGXH(snInvoiceDetail.getSpecificationModel()); |
|
|
|
|
if (snInvoice.getInvoiceCode() != null) { |
|
|
|
|
sapInvoiceDetail.setZTID(snInvoice.getInvoiceCode() + snInvoice.getInvoiceNumber() + snFplx); |
|
|
|
@ -912,7 +889,7 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
if (taxRate != null && !taxRate.contains("%")) { |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(taxRate); |
|
|
|
|
BigDecimal multiply = bigDecimal.multiply(new BigDecimal("100")); |
|
|
|
|
info.setZTAX(multiply.toPlainString()); |
|
|
|
|
info.setZTAX(multiply.toString()); |
|
|
|
|
info.setZSM(getZSM(taxRate)); |
|
|
|
|
} |
|
|
|
|
if (taxRate != null && taxRate.contains("%")) { |
|
|
|
@ -925,19 +902,20 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
info.setZSM(getZSM(divide.toString())); |
|
|
|
|
} |
|
|
|
|
if (taxRate != null && taxRate.contains(".") && !taxRate.contains("%")) { |
|
|
|
|
|
|
|
|
|
if (taxRate.length() > 4) { |
|
|
|
|
taxRate = taxRate.substring(0, 4); |
|
|
|
|
BigDecimal tax = new BigDecimal(taxRate); |
|
|
|
|
info.setZSM(getZSM(tax.toPlainString())); |
|
|
|
|
info.setZSM(getZSM(tax.toString())); |
|
|
|
|
BigDecimal tax1 = tax.multiply(new BigDecimal("100")); |
|
|
|
|
info.setZTAX(tax1.setScale(2, RoundingMode.FLOOR).toPlainString()); |
|
|
|
|
|
|
|
|
|
info.setZTAX(tax1.toString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (taxRate != null && "0".equals(taxRate)) { |
|
|
|
|
info.setZTAX("0.00"); |
|
|
|
|
info.setZSM(getZSM(info.getZTAX())); |
|
|
|
|
} |
|
|
|
|
if (invoiceLineList == null || invoiceLineList.size() == 0) { |
|
|
|
|
if (info.getZTAX() == null || "".equals(info.getZTAX())) { |
|
|
|
|
if (info.getZTAX() == null || info.getZTAX() == "") { |
|
|
|
|
info.setZTAX("0.00"); |
|
|
|
|
info.setZSM(getZSM(info.getZTAX())); |
|
|
|
|
} |
|
|
|
@ -1200,9 +1178,6 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
case "1.5": |
|
|
|
|
sm = "JA"; |
|
|
|
|
break; |
|
|
|
|
case "0.015": |
|
|
|
|
sm = "JA"; |
|
|
|
|
break; |
|
|
|
|
case "1": |
|
|
|
|
sm = "J9"; |
|
|
|
|
break; |
|
|
|
@ -1276,17 +1251,4 @@ public class SDNYMainProcessController extends AbstractController { |
|
|
|
|
} |
|
|
|
|
return ZCYJG; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查验发票 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/refresh") |
|
|
|
|
@ResponseBody |
|
|
|
|
@SysLog("发票查验") |
|
|
|
|
public String refreshDetailData(@RequestBody Map<String, Object> pramsMap) throws Exception { |
|
|
|
|
log.info("接口请求的参数为:{}", pramsMap); |
|
|
|
|
String result = snPushCheckRecordService.getRecords(pramsMap); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|