@ -106,7 +106,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
@Resource
private TdxPlatformCheckLogService platformCheckLogService ;
public String pushCheckResultToSAP ( String requestParam ) throws Exception {
public String pushCheckResultToSAP ( String requestParam ) {
log . info ( "获取请求参数:{} , 请求地址:{}" , requestParam , snYxUrl ) ;
String post = HttpUtils . sendPo ( snYxUrl , requestParam , userName , password ) ;
log . info ( "获取返回信息:{}" , post ) ;
@ -114,7 +114,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
return post ;
}
public String pushInvoiceToRecordInvoice ( SNInvoice snInvoice , String taxNo , String company , String imageId , String compCode ) throws Exception {
public String pushInvoiceToRecordInvoice ( SNInvoice snInvoice , String taxNo , String company , String imageId , String compCode ) {
TDxInvoiceReimburse recordInvoice = new TDxInvoiceReimburse ( ) ;
// DynamicContextHolder.push(DbConstant.BASICS_READ);
@ -459,20 +459,18 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
jsonObject . put ( "tonnage" , invoiceData . get ( "dw" ) ) ;
jsonObject . put ( "limitPeople" , invoiceData . get ( "xcrs" ) ) ;
String taxRate = "" ;
if ( invoiceData . get ( "sl" ) = = null | | StringUtils . isBlank ( invoiceData . get ( "sl" ) . toString ( ) ) | |
"免税" . equals ( invoiceData . get ( "sl" ) . toString ( ) ) | | "不征税" . equals ( invoiceData . get ( "sl" ) . toString ( ) ) | | "***" . equals ( invoiceData . get ( "sl" ) . toString ( ) ) ) {
if ( StringUtils . isBlank ( invoiceData . get ( "sl" ) . toString ( ) ) | | "免税" . equals ( invoiceData . get ( "sl" ) . toString ( ) ) | | "不征税" . equals ( invoiceData . get ( "sl" ) . toString ( ) ) | | "***" . equals ( invoiceData . get ( "sl" ) . toString ( ) ) ) {
taxRate = "0" ;
jsonObject . put ( "taxRate" , taxRate ) ;
} else {
if ( invoiceData . get ( "sl" ) ! = null & & StringUtils . isNoneBlank ( invoiceData . get ( "sl" ) . toString ( ) ) ) {
if ( StringUtils . isNoneBlank ( invoiceData . get ( "sl" ) . toString ( ) ) ) {
taxRate = invoiceData . get ( "sl" ) . toString ( ) ;
if ( ! "0" . equals ( taxRate ) ) {
taxRate = "0." + taxRate ;
taxRate = taxRate . substring ( 0 , taxRate . length ( ) - 1 ) ;
}
if ( "11" . equals ( invoiceType ) ) {
taxRate = "0.000 " ;
taxRate = "0" ;
}
log . info ( "明细-发票税率为:{}" , taxRate ) ;
jsonObject . put ( "taxRate" , taxRate ) ;
@ -557,13 +555,13 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
taxRateDetail = "0" ;
snDetailMap . put ( "taxRate" , taxRateDetail ) ;
} else {
if ( detail . get ( "sl" ) ! = null & & StringUtils . isNoneBlank ( detail . get ( "sl" ) . toString ( ) ) ) {
if ( StringUtils . isNoneBlank ( detail . get ( "sl" ) . toString ( ) ) ) {
taxRateDetail = detail . get ( "sl" ) . toString ( ) ;
if ( ! "0" . equals ( taxRateDetail ) ) {
if ( StringUtils . isNoneBlank ( taxRateDetail ) ) {
int index = taxRateDetail . indexOf ( "%" ) ;
if ( index > 0 ) {
taxRateDetail = taxRateDetail . substring ( 0 , taxRateDetail . length ( ) - 1 ) ;
// if (index > 0) {
// taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1);
// Float num = Float.parseFloat(taxRateDetail);
// if (num > 9) {
// taxRateDetail = "0." + taxRateDetail;
@ -572,7 +570,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
// taxRateDetail = "0.0" + taxRateDetail;
// }
// }
}
// }
}
}
@ -735,7 +733,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
log . error ( "补充查验失败,errormsg:{}" , e . getMessage ( ) ) ;
}
if ( ! checkInvoiceResult . containsKey ( "code" ) ) {
if ( checkInvoiceResult ! = null & & ! checkInvoiceResult . containsKey ( "code" ) ) {
if ( ! checkInvoiceResult . containsKey ( "cyjg" ) ) {
checkInvoiceResult . put ( "invoiceNo" , checkInvoiceResult . getString ( "invoiceNumber" ) ) ;
log . info ( "补充查验的结果为:{}" , checkInvoiceResult ) ;
@ -1020,8 +1018,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
* @return
* @throws ParseException
* /
public ServiceResult < InvoiceInfo > valoremTaxCount ( InvoiceInfo invoiceInfo , String isDeductible )
throws ParseException {
public ServiceResult < InvoiceInfo > valoremTaxCount ( InvoiceInfo invoiceInfo , String isDeductible ) {
if ( isDeductible = = null | | StringUtils . isEmpty ( isDeductible ) ) {
logger . error ( "客票价税计算失败:费用类别或可抵扣标识为空" ) ;
return fail ( "费用类别或可抵扣标识为空" ) ;
@ -1128,148 +1125,6 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
return typeList ;
}
/ * *
* @param invoiceInfo
* @return
* @throws ParseException
* /
private ServiceResult < ? > checkIsDeduction ( InvoiceInfo invoiceInfo ) throws ParseException {
try {
String result = verifyInfo ( invoiceInfo ) ;
if ( ! CommonEnum . RESPONSE_INTERFACE_STATUS_CODE_SUCCESS . equals ( result ) ) {
return fail ( result ) ;
}
if ( Constant . VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE . equals ( invoiceInfo . getInvoiceTypeCode ( ) )
| | Constant . VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE
. equals ( invoiceInfo . getInvoiceTypeCode ( ) ) ) {
if ( invoiceInfo . getDetailList ( ) ! = null ) {
if ( invoiceInfo . getDetailList ( ) = = null | | invoiceInfo . getDetailList ( ) . isEmpty ( ) ) {
return fail ( "发票明细不可为空" ) ;
}
// 校验增值税电子普通发票
String invoiceTypeCode = invoiceInfo . getInvoiceTypeCode ( ) ;
if ( invoiceTypeCode . equals ( Constant . VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE )
| | invoiceTypeCode . equals ( Constant . VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE ) ) {
List < InvoiceDetail > details = invoiceInfo . getDetailList ( ) ;
if ( details ! = null & & details . size ( ) > 0 ) {
for ( int i = 0 , length = details . size ( ) ; i < length ; i + + ) {
if ( ! isRightRule ( details . get ( i ) . getGoodsName ( ) , details . get ( i ) . getTaxRate ( ) ) ) {
return fail ( "发票底账明细中第" + i + 1 + "条名称或税率不正确" ) ;
}
if ( StringUtils . isNotEmpty ( details . get ( i ) . getTaxRate ( ) ) ) {
if ( details . get ( i ) . getTaxRate ( ) . contains ( "%" ) ) {
invoiceInfo . setTaxRate ( details . get ( i ) . getTaxRate ( ) ) ;
} else {
invoiceInfo . setTaxRate ( details . get ( i ) . getTaxRate ( ) + "%" ) ;
}
}
}
}
}
} else {
return fail ( "未获取到发票明细" ) ;
}
}
// // 校验公路、水路、其他运输客票(实名),航空客运电子客票行程单,火车票
// if (invoiceInfo.getInvoiceTypeCode().equals(Constant.ROAD_TRANSPORT_TICKET_REAL_NAME_CODE)
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.WATER_TRANSPORT_TICKET_REAL_NAME_CODE)
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.OTHER_TRANSPORT_TICKET_REAL_NAME_CODE)
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.AIR_PASSENGER_ELECTRONIC_TICKET_ITINERARY_CODE)
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.RAILWAY_TICKET_CODE)) {
// if (StringUtils.isEmpty(invoiceInfo.getIdentityNumber())
// || StringUtils.isEmpty(invoiceInfo.getPassenger())) {
// return fail("必填字段为空");
// }
// int count = orgUserInfoDao.countUserByIdentityNumber(invoiceInfo.getIdentityNumber(),
// invoiceInfo.getPassenger(), enterpriseId);
// if (count == 0) {
// return fail("未查询到用户信息");
// }
// if (count > 1) {
// return fail("查询到多个用户");
// }
// }
return ok ( ) ;
} catch ( Exception e ) {
logger . error ( "校验客运发票是否可抵扣异常:" + e . toString ( ) ) ;
return fail ( "客运发票是否可抵扣校验失败" ) ;
}
}
public String verifyInfo ( InvoiceInfo invoiceInfo ) {
String result = "0000" ;
if ( invoiceInfo = = null ) {
result = "发票信息不可为空" ;
}
if ( invoiceInfo . getInvoiceTypeCode ( ) = = null | | "" . equals ( invoiceInfo . getInvoiceTypeCode ( ) ) ) {
result = "发票类型不可为空" ;
}
if ( invoiceInfo . getInvoiceDate ( ) = = null | | "" . equals ( invoiceInfo . getInvoiceDate ( ) ) ) {
result = "开票日期不可为空" ;
}
if ( ! CommonEnum . INV_ZZS_ELE_PP . equals ( invoiceInfo . getInvoiceTypeCode ( ) ) & & ! CommonEnum . INV_ZZS_ELE_TXF . equals ( invoiceInfo . getInvoiceTypeCode ( ) ) ) {
if ( invoiceInfo . getIdentityNumber ( ) = = null | | "" . equals ( invoiceInfo . getIdentityNumber ( ) ) ) {
result = "用户证件号不可为空" ;
}
if ( invoiceInfo . getPassenger ( ) = = null | | "" . equals ( invoiceInfo . getPassenger ( ) ) ) {
result = "乘车人不可为空" ;
}
if ( invoiceInfo . getDepartCity ( ) = = null | | invoiceInfo . getDepartCity ( ) . isEmpty ( ) ) {
result = "出发城市不可为空" ;
}
if ( invoiceInfo . getArriveCity ( ) = = null | | invoiceInfo . getArriveCity ( ) . isEmpty ( ) ) {
result = "到达城市不可为空" ;
}
}
if ( invoiceInfo . getInvoiceDate ( )
. compareTo ( DateUtil . parse ( "2019-04-01" , DatePattern . NORM_DATE_PATTERN ) ) < 0 ) {
result = "开票日期需要晚于2019年4月1日" ;
}
DynamicContextHolder . push ( DbConstant . BASICS_READ ) ;
if ( ! invoiceInfo . getInvoiceTypeCode ( ) . equals ( Constant . VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE )
& & ! invoiceInfo . getInvoiceTypeCode ( )
. equals ( Constant . VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE ) ) {
// 港澳台城市
List < String > hmtList = new ArrayList < > ( ) ;
// 香港
hmtList . add ( "香港特别行政区" ) ;
hmtList . add ( "香港" ) ;
// 澳门
hmtList . add ( "澳门特别行政区" ) ;
hmtList . add ( "澳门" ) ;
// 台湾
hmtList . add ( "台湾省" ) ;
hmtList . add ( "台湾" ) ;
// 出发地和到达地是否为非港澳台城市
List < Area > departCities = areaDao . queryAreaByName ( invoiceInfo . getDepartCity ( ) ) ;
List < Area > arriveCities = areaDao . queryAreaByName ( invoiceInfo . getArriveCity ( ) ) ;
boolean invHmtListExisted = ( StringUtils . isNotEmpty ( invoiceInfo . getDepartCity ( ) )
& & hmtList . contains ( invoiceInfo . getDepartCity ( ) ) )
| | ( StringUtils . isNotEmpty ( invoiceInfo . getArriveCity ( ) )
& & hmtList . contains ( invoiceInfo . getArriveCity ( ) ) ) ;
if ( departCities = = null | | departCities . isEmpty ( ) | | arriveCities = = null | | arriveCities . isEmpty ( ) ) {
result = "出发或到达城市不符合标准" ;
} else if ( invHmtListExisted ) {
result = "出发或到达城市不符合标准" ;
}
}
return result ;
}
/ * *
* 增值税电子普通发票验证逻辑
*
* @param goodsName
* @param rate
* @return
* /
private Boolean isRightRule ( String goodsName , String rate ) {
return ( goodsName . contains ( "*运输服务*" ) ) & & ( rate . contains ( "3" ) | | rate . contains ( "9" ) ) ;
}
public static boolean isBigDecimal ( String str ) {
if ( str = = null | | str . trim ( ) . length ( ) = = 0 ) {
return false ;