|
|
|
@ -14,13 +14,12 @@ import com.dxhy.erp.dao.BaseReceiptOutDao; |
|
|
|
|
import com.dxhy.erp.entity.BaseInvoiceEditVO; |
|
|
|
|
import com.dxhy.erp.entity.BaseTDxRecordInvoice; |
|
|
|
|
import com.dxhy.erp.entity.BaseTDxRecordInvoiceOut; |
|
|
|
|
import com.dxhy.erp.model.ErpInvoiceData; |
|
|
|
|
import com.dxhy.erp.model.EsOutPutResp; |
|
|
|
|
import com.dxhy.erp.model.OutPut; |
|
|
|
|
import com.dxhy.erp.model.*; |
|
|
|
|
import com.dxhy.erp.service.BaseIReceiptInvoiceService; |
|
|
|
|
import com.dxhy.erp.service.IReceiptOutService; |
|
|
|
|
import com.dxhy.erp.utils.JsonUtils; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
@ -52,13 +51,7 @@ public class ReceiptOutServiceImpl extends MpBaseServiceImpl<BaseReceiptOutDao, |
|
|
|
|
|
|
|
|
|
// first:查询出底账表相关数据
|
|
|
|
|
List<BaseTDxRecordInvoice> invoices = baseIReceiptInvoiceService.selectByUuids(ids); |
|
|
|
|
if(CollectionUtils.isEmpty(invoices)){ |
|
|
|
|
return TransferContant.INVOICE_NOT_EXIT; |
|
|
|
|
} |
|
|
|
|
invoices = invoices.stream().filter(e -> !"0".equals(e.getRzhYesorno())).collect(Collectors.toList()); |
|
|
|
|
if(CollectionUtils.isEmpty(invoices)){ |
|
|
|
|
return TransferContant.NOT_RZ; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// second:根据uuids查询出转出明细并转为map,key=uuid ,value=转出明细
|
|
|
|
|
List<BaseTDxRecordInvoiceOut> outs = listByUuids(ids); |
|
|
|
|
Map<String, BaseTDxRecordInvoiceOut> outMap = |
|
|
|
@ -80,11 +73,34 @@ public class ReceiptOutServiceImpl extends MpBaseServiceImpl<BaseReceiptOutDao, |
|
|
|
|
outList.add(e); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE); |
|
|
|
|
excuteTransferWrite(condList, outList); |
|
|
|
|
|
|
|
|
|
return TransferContant.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public String transferOrcancelOut(List<ZDATAN> zdatans,UserInfo userInfo){ |
|
|
|
|
String result = ""; |
|
|
|
|
for (ZDATAN zdata : zdatans) { |
|
|
|
|
//转出税额大于1则是转出
|
|
|
|
|
if (zdata.getJXSZC().compareTo(BigDecimal.ZERO)==1){ |
|
|
|
|
BaseInvoiceEditVO baseInvoiceEditVO = new BaseInvoiceEditVO(); |
|
|
|
|
baseInvoiceEditVO.setPrimaryKey(zdata.getZFPDM()==null?"":zdata.getZFPDM()+zdata.getZFPHM()); |
|
|
|
|
baseInvoiceEditVO.setOutReason(zdata.getZZCYY()); |
|
|
|
|
baseInvoiceEditVO.setOutTax(zdata.getJXSZC().toPlainString()); |
|
|
|
|
baseInvoiceEditVO.setOutStatus("1"); |
|
|
|
|
baseInvoiceEditVO.setOutTaxPeriod(zdata.getBUDAT()); |
|
|
|
|
this.transfer(baseInvoiceEditVO,userInfo); |
|
|
|
|
}else {//转出税额小于0取消转出
|
|
|
|
|
BaseReceiptOutCancelEditReqVO baseReceiptOutCancelEditReqVO = new BaseReceiptOutCancelEditReqVO(); |
|
|
|
|
baseReceiptOutCancelEditReqVO.setPrimaryKey(zdata.getZFPDM()==null?"":zdata.getZFPDM()+zdata.getZFPHM()); |
|
|
|
|
baseIReceiptInvoiceService.cancelOut(baseReceiptOutCancelEditReqVO); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return TransferContant.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据uuids查询进项税转出明细 |
|
|
|
|
* |
|
|
|
@ -137,10 +153,19 @@ public class ReceiptOutServiceImpl extends MpBaseServiceImpl<BaseReceiptOutDao, |
|
|
|
|
} |
|
|
|
|
/*全部转出 */ |
|
|
|
|
if (JxszcZtEnum.QBZC.getZcztDm().equals(condVO.getOutStatus())) { |
|
|
|
|
if (record.getOutTaxAmount() != null && record.getOutTaxAmount().compareTo(BigDecimal.ZERO)>0){ |
|
|
|
|
throw new RuntimeException("累计转出税额不能大于发票税额"); |
|
|
|
|
} |
|
|
|
|
// 转出金额
|
|
|
|
|
condRecord.setOutInvoiceAmout(record.getInvoiceAmount()); |
|
|
|
|
// 转出税额
|
|
|
|
|
condRecord.setOutTaxAmount(record.getDkTaxAmount()); |
|
|
|
|
if (condRecord.getOutTaxAmount() == null){ |
|
|
|
|
condRecord.setOutTaxAmount(new BigDecimal(condVO.getOutTax())); |
|
|
|
|
} |
|
|
|
|
if (condRecord.getOutTaxAmount().compareTo(record.getTaxAmount()) > 0){ |
|
|
|
|
throw new RuntimeException("转出税额不能大于发票税额"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/*部分转出 */ |
|
|
|
|
if (JxszcZtEnum.BFZC.getZcztDm().equals(condVO.getOutStatus())) { |
|
|
|
@ -206,10 +231,19 @@ public class ReceiptOutServiceImpl extends MpBaseServiceImpl<BaseReceiptOutDao, |
|
|
|
|
|
|
|
|
|
/* 全部转出 */ |
|
|
|
|
if (JxszcZtEnum.QBZC.getZcztDm().equals(condVO.getOutStatus())) { |
|
|
|
|
if (invoice.getOutTaxAmount() != null && invoice.getOutTaxAmount().compareTo(BigDecimal.ZERO)>0){ |
|
|
|
|
throw new RuntimeException("累计转出税额不能大于发票税额"); |
|
|
|
|
} |
|
|
|
|
// 转出金额
|
|
|
|
|
record.setOutInvoiceAmout(invoice.getInvoiceAmount()); |
|
|
|
|
// 转出税额
|
|
|
|
|
record.setOutTaxAmount(invoice.getDkTaxAmount()); |
|
|
|
|
if (record.getOutTaxAmount() == null){ |
|
|
|
|
record.setOutTaxAmount(new BigDecimal(condVO.getOutTax())); |
|
|
|
|
} |
|
|
|
|
if (record.getOutTaxAmount().compareTo(invoice.getTaxAmount()) > 0){ |
|
|
|
|
throw new RuntimeException("转出税额不能大于发票税额"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/* 部分转出 */ |
|
|
|
|
if (JxszcZtEnum.BFZC.getZcztDm().equals(condVO.getOutStatus())) { |
|
|
|
|