md
This commit is contained in:
parent
7a1c9ddfaa
commit
a672a52f1d
@ -1072,7 +1072,6 @@ public class EmisBaseService {
|
||||
public void redoGenerateBill(String billCode) throws EmisBizError{
|
||||
log.error("===>Start 运单出账:"+billCode);
|
||||
|
||||
|
||||
boolean isNewBill=true;
|
||||
BigDecimal oldTotalFee = BigDecimal.ZERO;
|
||||
BigDecimal newTotalFee = BigDecimal.ZERO;
|
||||
@ -1080,6 +1079,12 @@ public class EmisBaseService {
|
||||
// 已确认的不允许出账
|
||||
List<EmisSettleSubBill> oldSubBillList=getSettleSubBillListByBillCode(billCode);
|
||||
if(!CollectionUtils.isEmpty(oldSubBillList) ) {
|
||||
|
||||
if(oldSubBillList.size()>1){
|
||||
log.error("===>已拆子账单不允许出账!");
|
||||
return;
|
||||
}
|
||||
|
||||
isNewBill=false;
|
||||
for (EmisSettleSubBill oldBill:oldSubBillList) {
|
||||
if ("1".equals(oldBill.getBlConfirmCenter())) {
|
||||
@ -1094,14 +1099,7 @@ public class EmisBaseService {
|
||||
EmisWaybill dt=emisWaybillMapper.selectEmisWaybillByBillCode(billCode);
|
||||
|
||||
// 生成分账单明细,判断是否是新账单
|
||||
EmisSettleSubBill emisSettleSubBill=new EmisSettleSubBill();
|
||||
if(!isNewBill){
|
||||
// 逻辑删除原账单重出账单
|
||||
emisSettleSubBillMapper.deleteEmisSettleSubBillByBillCode(billCode);
|
||||
// 逻辑删除原来的费用明细,重新插入明细
|
||||
emisSettleSubBillFeeitemMapper.deleteEmisSettleSubBillFeeitemByBillCode(billCode);
|
||||
}
|
||||
|
||||
EmisSettleSubBill emisSettleSubBill=new EmisSettleSubBill();
|
||||
emisSettleSubBill.setBillCode(dt.getBillCode());
|
||||
emisSettleSubBill.setBillNo(dt.getBillCode());
|
||||
emisSettleSubBill.setBillDate(new Date());
|
||||
@ -1126,9 +1124,6 @@ public class EmisBaseService {
|
||||
emisSettleSubBill.setCurrency(dt.getCurrency());
|
||||
emisSettleSubBill.setBillMonth(DateUtils.parseDateToStr("yyyyMM",dt.getSendDate()));
|
||||
|
||||
|
||||
|
||||
|
||||
emisSettleSubBill.setBillFee(dt.getFreight());
|
||||
|
||||
emisSettleSubBill.setCustNo(dt.getCustNo());
|
||||
@ -1145,7 +1140,15 @@ public class EmisBaseService {
|
||||
emisSettleSubBill.setBlConfirmSite("0");
|
||||
emisSettleSubBill.setBlConfirmCenter("0");
|
||||
|
||||
emisSettleSubBillMapper.insertEmisSettleSubBill(emisSettleSubBill);
|
||||
if(isNewBill){
|
||||
emisSettleSubBillMapper.insertEmisSettleSubBill(emisSettleSubBill);
|
||||
}else{
|
||||
// 删除旧明细数据
|
||||
emisSettleSubBillFeeitemMapper.deleteEmisSettleSubBillFeeitemByBillCode(billCode);
|
||||
// 旧账单,只允许调整
|
||||
emisSettleSubBill.setId(oldSubBillList.get(0).getId());
|
||||
emisSettleSubBillMapper.updateEmisSettleSubBill(emisSettleSubBill);
|
||||
}
|
||||
|
||||
// 新费用
|
||||
newTotalFee = emisSettleSubBill.getBillFee();
|
||||
@ -1153,6 +1156,7 @@ public class EmisBaseService {
|
||||
// 如果是一口价,自动生成一条运费明细,其他则根据实际来计算
|
||||
// 生成费用明细
|
||||
if(dt.getCalcFeeType().equals("3")) {
|
||||
|
||||
}else{
|
||||
// 产生新的费用明细
|
||||
List<EmisWaybillFeeitem> feeitemList = emisWaybillFeeitemMapper.selectFeeitemListByWaybillId(dt.getId());
|
||||
@ -2646,7 +2650,7 @@ public class EmisBaseService {
|
||||
}
|
||||
|
||||
if (isBillLock(emisWaybill)) {
|
||||
throw new EmisBizError(EmisBizErrorType.BILL_LOCK, "已锁账,不允许修改");
|
||||
throw new EmisBizError(EmisBizErrorType.BILL_LOCK, "已锁账:"+emisWaybill.getLockReason());
|
||||
}
|
||||
|
||||
if (isOutTimeLock(emisWaybill)) {
|
||||
@ -2669,12 +2673,14 @@ public class EmisBaseService {
|
||||
|
||||
if(emisSettleSubBillList.size()>1) {
|
||||
// 已分单不允许修改
|
||||
emisWaybill.setLockReason("已拆子单,不允许修改");
|
||||
return true;
|
||||
}else {
|
||||
|
||||
EmisSettleSubBill emisSettleSubBill = emisSettleSubBillList.get(0);
|
||||
if ("1".equals(emisSettleSubBill.getBlConfirmCenter())) {
|
||||
// 财务确认出账明细锁账
|
||||
emisWaybill.setLockReason("财务已确认,不允许修改");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2683,6 +2689,7 @@ public class EmisBaseService {
|
||||
|| "2".equals(emisSettleSubBill.getBlConfirmSite())
|
||||
) {
|
||||
// 财务确认出账明细锁账
|
||||
emisWaybill.setLockReason("已确认不出账,不允许修改");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2697,12 +2704,12 @@ public class EmisBaseService {
|
||||
int rst=emisSiteBillControlMapper.checkBillIsLock(emisSiteBillControl);
|
||||
|
||||
if(rst>0){
|
||||
emisWaybill.setLockReason("已确认不出账,不允许修改");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -209,6 +209,7 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen
|
||||
@Override
|
||||
public int deleteEmisSettleInvoiceRecordById(Long id)
|
||||
{
|
||||
// 如果已开票不允许删除
|
||||
return emisSettleInvoiceRecordMapper.deleteEmisSettleInvoiceRecordById(id);
|
||||
}
|
||||
|
||||
|
||||
@ -99,6 +99,15 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"账单编号不能为空");
|
||||
}
|
||||
|
||||
if(emisSettlePayRecord.getPayMoney()==null|| BigDecimal.ZERO.compareTo(emisSettlePayRecord.getPayMoney())==0 ){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"收款金额不能为0");
|
||||
}
|
||||
|
||||
EmisSettleBill emisSettleBill=emisSettleBillMapper.selectSettleBillBySettleBillNo(emisSettlePayRecord.getSettleBillNo());
|
||||
if(!"1".equals(emisSettleBill.getBlConfirmSite()) ){
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,"业务账单未确认,不允许收款!");
|
||||
}
|
||||
|
||||
// 不重复的 id流水号
|
||||
String payId= WaybillHelper.genPayId();
|
||||
emisSettlePayRecord.setPayId(payId);
|
||||
@ -122,10 +131,15 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
EmisSettleBill oldBill =getSettleBillBySettleBillNo(settleBillNo);
|
||||
// 获取收款记录
|
||||
List<EmisSettlePayRecord> payRecordList=emisSettlePayRecordMapper.selectSettlePayRecordListBySettleBillNo(settleBillNo);
|
||||
|
||||
// 全部收款金额
|
||||
BigDecimal totalAllPayMoney = BigDecimal.ZERO;
|
||||
|
||||
|
||||
// 计算已收款金额
|
||||
BigDecimal totalPayMoney = BigDecimal.ZERO;
|
||||
// 抵扣金额
|
||||
|
||||
// 抵扣金额
|
||||
BigDecimal satisfyMoney = BigDecimal.ZERO;
|
||||
/* allowance_money */
|
||||
BigDecimal allowanceMoney = BigDecimal.ZERO;
|
||||
@ -140,6 +154,12 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
allowanceMoney=allowanceMoney.add(item.getAllowanceMoney()==null?BigDecimal.ZERO:item.getAllowanceMoney());
|
||||
deductionMoney=deductionMoney.add(item.getDeductionMoney()==null?BigDecimal.ZERO:item.getDeductionMoney());
|
||||
otherMoney=otherMoney.add(item.getOtherMoney()==null?BigDecimal.ZERO:item.getOtherMoney());
|
||||
|
||||
totalAllPayMoney=totalAllPayMoney.add(totalPayMoney);
|
||||
totalAllPayMoney=totalAllPayMoney.add(satisfyMoney);
|
||||
totalAllPayMoney=totalAllPayMoney.add(allowanceMoney);
|
||||
totalAllPayMoney=totalAllPayMoney.add(deductionMoney);
|
||||
totalAllPayMoney=totalAllPayMoney.add(otherMoney);
|
||||
}
|
||||
|
||||
EmisSettleBill newBill = new EmisSettleBill();
|
||||
@ -150,7 +170,7 @@ public class EmisSettlePayRecordServiceImpl extends EmisBaseService implements I
|
||||
newBill.setOtherMoney(otherMoney);
|
||||
|
||||
// 判断收款状态 收款金额
|
||||
int rstDif=totalPayMoney.compareTo(oldBill.getRecMoney());
|
||||
int rstDif=totalAllPayMoney.compareTo(oldBill.getRecMoney());
|
||||
if( rstDif >= 0 ){
|
||||
// 已收款
|
||||
newBill.setPaymentStatus("1");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user