Browse Source

交回车辆入库:财务扣回入库凭证+其他入库单添加挂车信息

master
dimengzhe 4 weeks ago
parent
commit
090e79de76
  1. 2
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/LoanRepaymentPlanDetailsMapper.java
  2. 82
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/LoanRepaymentPlanDetailsMapper.xml
  3. 6
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/LoanRepaymentPlanDetailsService.java
  4. 41
      anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanreturninboundapply/LoanReturnInboundApplyService.java

2
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/LoanRepaymentPlanDetailsMapper.java

@ -115,4 +115,6 @@ public interface LoanRepaymentPlanDetailsMapper extends BaseMapper<LoanRepayment
String selByBusVinSid(@Param("saleVehSid") String saleVehSid,@Param("date") String date);
String selByBusVinSidMax(String saleVehSid);
String getWdq(String busVinSid);
}

82
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/LoanRepaymentPlanDetailsMapper.xml

@ -944,8 +944,7 @@
SELECT
ROUND(
SUM(ss.yq_total) +
COALESCE(lbpv_sum.bankBeInter_sum, 0) +
COALESCE(lfd_sum.fund_sum, 0),
COALESCE(lbpv_sum.bankBeInter_sum, 0),
2) AS beMoney
FROM (
SELECT
@ -968,51 +967,30 @@
WHERE saleVehSid = #{busVinSid}
GROUP BY saleVehSid
) lbpv_sum ON lbpv_sum.saleVehSid = ss.busVinSid
LEFT JOIN (
SELECT
a.busVinSid,
SUM(a.fund) AS fund_sum
FROM (
SELECT
(fjj.reveivableMoney - fjj.m) AS fund,
lp.busVinSid
FROM (
SELECT IFNULL((
SELECT SUM(subscriptionMoney)
FROM anrui_fin.fin_selected_receivables_detailed AS s
WHERE s.auditState = '3'
AND s.receivablesSid = fj.sid
), 0) AS m,
fj.*
FROM (
SELECT j.busSid, j.sid, j.reveivableMoney
FROM anrui_fin.fin_uncollected_receivables_detailed_jr AS j
WHERE j.payCostTitleKey = '006'
) AS fj
) AS fjj
LEFT JOIN loan_repayment_plan_details lp
ON lp.sid = fjj.busSid
WHERE lp.dueDate &lt;= lp.updateTime
AND lp.busVinSid = #{busVinSid}
) a
GROUP BY a.busVinSid
) lfd_sum ON lfd_sum.busVinSid = ss.busVinSid
</select>
<select id="getBj" resultType="java.lang.String">
select sum(ss.yq_total) from (
SELECT
lrpd.sid,
lrpd.busVinSid,
(lrpd.dueMoney - COALESCE(SUM(lrh.actualMoney), 0)) AS yq_total
FROM loan_repayment_plan_details lrpd
LEFT JOIN loan_repayment_history lrh
ON lrh.planDetailSid = lrpd.sid
WHERE lrpd.dueDate &lt;= lrpd.updateTime
AND lrpd.busVinSid =#{busVinSid}
AND lrpd.oweState = '1'
GROUP BY lrpd.sid)ss
SUM(principal_amount) AS total_principal
FROM (
SELECT
lrpd.sid,
lrpd.busVinSid,
(lrpd.dueMoney - COALESCE(SUM(lrh.actualMoney), 0)) AS principal_amount
FROM
loan_repayment_plan_details lrpd
LEFT JOIN
loan_repayment_history lrh ON lrh.planDetailSid = lrpd.sid
WHERE
lrpd.busVinSid = #{busVinSid}
AND lrpd.oweState = '1' -- 是否转累欠状态为"否"(1)
AND lrpd.dueDate BETWEEN
DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') -- 本月第一天
AND LAST_DAY(CURRENT_DATE) -- 本月最后一天
GROUP BY
lrpd.sid, lrpd.busVinSid, lrpd.dueMoney
) AS principal_details
</select>
@ -1031,4 +1009,24 @@
ORDER BY period DESC
LIMIT 1
</select>
<select id="getWdq" resultType="java.lang.String">
SELECT
SUM(future_due_amount) AS total_future_due
FROM (
SELECT
lrpd.sid,
lrpd.busVinSid,
(lrpd.dueMoney - COALESCE(SUM(lrh.actualMoney), 0)) AS future_due_amount
FROM
loan_repayment_plan_details lrpd
LEFT JOIN
loan_repayment_history lrh ON lrh.planDetailSid = lrpd.sid
WHERE
lrpd.busVinSid = #{busVinSid}
AND lrpd.dueDate > LAST_DAY(CURRENT_DATE) -- 应还日期在当月之后
GROUP BY
lrpd.sid, lrpd.busVinSid, lrpd.dueMoney
) AS future_due_details
</select>
</mapper>

6
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanrepaymentplandetails/LoanRepaymentPlanDetailsService.java

@ -383,7 +383,7 @@ public class LoanRepaymentPlanDetailsService extends MybatisBaseService<LoanRepa
public String getYqLq(String busVinSid) {
return baseMapper.getYqLq(busVinSid);
}
//应收贷款车欠款_到期欠款_本金
public String getBj(String busVinSid) {
return baseMapper.getBj(busVinSid);
}
@ -395,4 +395,8 @@ public class LoanRepaymentPlanDetailsService extends MybatisBaseService<LoanRepa
public String selByBusVinSidMax(String saleVehSid) {
return baseMapper.selByBusVinSidMax(saleVehSid);
}
public String getWdq(String busVinSid) {
return baseMapper.getWdq(busVinSid);
}
}

41
anrui-riskcenter/anrui-riskcenter-biz/src/main/java/com/yxt/anrui/riskcenter/biz/loanreturninboundapply/LoanReturnInboundApplyService.java

@ -709,7 +709,13 @@ public class LoanReturnInboundApplyService extends MybatisBaseService<LoanReturn
customerNumber = busSalesOrderVehicle.getTemporaryNo();
}
}
AlrepaidAndArrVo alrepaidAndArrVo = loanRestoreReportApplyService.getAlrepaidAndArr2(loanReturnInboundApply.getBusVinSid());
//----------------------计算规则------------------------------------
//扣回入库推送凭证包含以下:
//1、累欠 = 该车的还款明细中是否转累欠状态为是0的逾期的未还金额+垫资方逾期利息余额
//2、未到期欠款 = 该车的还款明细中应还日期在当月之后的未还金额之和
//3、本金 = 该车的还款明细中是否转累欠状态为否1的且应还日期是本月的未还金额
//4、扣回车辆 = 累欠+未到期欠款+本金
//应收贷款车欠款_待处理欠款_扣回车辆
BigDecimal all = BigDecimal.ZERO;
//应收贷款车欠款_到期欠款_累欠
@ -721,23 +727,17 @@ public class LoanReturnInboundApplyService extends MybatisBaseService<LoanReturn
String lq = loanRepaymentPlanDetailsService.getYqLq(loanReturnInboundApply.getBusVinSid());
lqMoney = lqMoney.add(new BigDecimal(StringUtils.isBlank(lq) ? "0" : lq));
//未到期欠款
String wdq = alrepaidAndArrVo.getUnexpiredMoney();
String wdq = loanRepaymentPlanDetailsService.getWdq(loanReturnInboundApply.getBusVinSid());
wdqMoney = wdqMoney.add(new BigDecimal(StringUtils.isBlank(wdq) ? "0" : wdq));
String bj = loanRepaymentPlanDetailsService.getBj(loanReturnInboundApply.getBusVinSid());
bjMoney = bjMoney.add(new BigDecimal(StringUtils.isBlank(bj) ? "0" : bj));
all = lqMoney.add(wdqMoney).add(bjMoney);
List<Voucher.VoucherResultDetailDto> voucherResultDetailDtos = new ArrayList<>();
//借方
Voucher.VoucherResultDetailDto voucherResultDetailDtoJf = new Voucher.VoucherResultDetailDto();
//贷方
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf1 = new Voucher.VoucherResultDetailDto();
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf2 = new Voucher.VoucherResultDetailDto();
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf3 = new Voucher.VoucherResultDetailDto();
//-------------------------------------------应收贷款车欠款_待处理欠款_扣回车辆
if (all.compareTo(BigDecimal.ZERO) != 0) {
//借方
Voucher.VoucherResultDetailDto voucherResultDetailDtoJf = new Voucher.VoucherResultDetailDto();
voucherResultDetailDtoJf.setSummary("扣回车辆入库");
voucherResultDetailDtoJf.setSubjectNo("1201.03.01");
//核算部门
@ -747,9 +747,10 @@ public class LoanReturnInboundApplyService extends MybatisBaseService<LoanReturn
voucherResultDetailDtoJf.setDebit(all.toString());
voucherResultDetailDtos.add(voucherResultDetailDtoJf);
}
//---------------------------------------------应收贷款车欠款_到期欠款_累欠
//---------------------------------------------应收贷款车欠款_到期欠款_累欠---是否转累欠状态为0的未还金额+垫资方逾期利息月
if (lqMoney.compareTo(BigDecimal.ZERO) != 0) {
//贷方
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf1 = new Voucher.VoucherResultDetailDto();
voucherResultDetailDtoDf1.setSummary("扣回车辆入库");
voucherResultDetailDtoDf1.setSubjectNo("1201.02.03");
//核算部门
@ -760,8 +761,9 @@ public class LoanReturnInboundApplyService extends MybatisBaseService<LoanReturn
voucherResultDetailDtos.add(voucherResultDetailDtoDf1);
}
//--------------------------------------------应收贷款车欠款_未到期欠款_未到期欠款
//--------------------------------------------应收贷款车欠款_未到期欠款_未到期欠款--按当月算,应还日期在当月之后的
if (wdqMoney.compareTo(BigDecimal.ZERO) != 0) {
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf2 = new Voucher.VoucherResultDetailDto();
voucherResultDetailDtoDf2.setSummary("扣回车辆入库");
voucherResultDetailDtoDf2.setSubjectNo("1201.01.00");
//核算部门
@ -772,8 +774,9 @@ public class LoanReturnInboundApplyService extends MybatisBaseService<LoanReturn
voucherResultDetailDtos.add(voucherResultDetailDtoDf2);
}
//-------------------------------------------应收贷款车欠款_到期欠款_本金
//-------------------------------------------应收贷款车欠款_到期欠款_本金-----应还日期是本月的都算本金,没有转累欠的
if (bjMoney.compareTo(BigDecimal.ZERO) != 0) {
Voucher.VoucherResultDetailDto voucherResultDetailDtoDf3 = new Voucher.VoucherResultDetailDto();
voucherResultDetailDtoDf3.setSummary("扣回车辆入库");
voucherResultDetailDtoDf3.setSubjectNo("1201.02.01");
//核算部门
@ -806,6 +809,16 @@ public class LoanReturnInboundApplyService extends MybatisBaseService<LoanReturn
stkMiscellaneousEntry.setFSTOCKID("ARZSCK");
stkMiscellaneousEntry.setFOWNERID(sysOrg.getOrgCode());
stkMiscellaneousEntryList.add(stkMiscellaneousEntry);
if ("是".equals(loanReturnInboundApply.getTralier())) {//挂车
LoanReturnInboundTrailer loanReturnInboundTrailer = loanReturnInboundTrailerService.selectByMainSid(loanReturnInboundApply.getSid());
stkMiscellaneousEntry = new StkMiscellaneous.StkMiscellaneousEntry();
stkMiscellaneousEntry.setFMATERIALID(loanReturnInboundTrailer.getVinNo());
stkMiscellaneousEntry.setFUnitID("liang");
stkMiscellaneousEntry.setFSTOCKID("ARZSCK");
stkMiscellaneousEntry.setFOWNERID(sysOrg.getOrgCode());
stkMiscellaneousEntryList.add(stkMiscellaneousEntry);
}
stkMiscellaneous.setStkMiscellaneousEntry(stkMiscellaneousEntryList);
ResultBean resultBean = finKingDeeFeign.draftStkMiscellaneous(stkMiscellaneous);

Loading…
Cancel
Save