Przeglądaj źródła

修改bug:
私有应收,开票记录是已结算,结算报表显示结算金额为0

jiakai 3 miesięcy temu
rodzic
commit
e8d1875c6f

+ 2 - 1
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -236,7 +236,8 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
     List<CalRes> querySettledAmount(@Param("systemCode") String systemCode,
                                     @Param("settledStartDate") String settledStartDate,
                                     @Param("settledEndDate") String settledEndDate,
-                                    @Param("agreementType") String agreementType);
+                                    @Param("agreementType") String agreementType,
+                                    @Param("invoiceTypes") List<String> invoiceTypes);
 
     /**
      * 查询

+ 4 - 3
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -3170,9 +3170,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         Map<String, BigDecimal> ptInvoicedAmountMap =calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getAmount, (o1,o2)->o1));
 
         // 结算费用 
-        calRes = baseMapper.querySettledAmount(systemCode, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType());
-        Map<String, BigDecimal> sxfSettledAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getSxfSettlement, (o1,o2)->o1));
-        Map<String, BigDecimal> gdfSettledAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getGdfSettlement, (o1,o2)->o1));
+        List<CalRes> sxfList = baseMapper.querySettledAmount(systemCode, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType(), CollUtil.newArrayList("1", "3"));
+        List<CalRes> gdfList = baseMapper.querySettledAmount(systemCode, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType(), CollUtil.newArrayList("2", "4"));
+        Map<String, BigDecimal> sxfSettledAmountMap = CollUtil.isNotEmpty(sxfList) ? sxfList.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getSettlement, (o1,o2)->o1)) : new HashMap<>();
+        Map<String, BigDecimal> gdfSettledAmountMap = CollUtil.isNotEmpty(gdfList) ? gdfList.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getSettlement, (o1,o2)->o1)) : new HashMap<>();
 
         // 计算已开票和未开票
         for (String companyId : companyMap.keySet()) {

+ 24 - 19
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -1688,37 +1688,42 @@
     <select id="querySettledAmount" resultType="com.jzg.organization.entity.dto.CalRes">
         select
         a.company_id ,
-        sum(COALESCE(a.jq_supervise_costs_premiums, 0)+ COALESCE(a.sy_supervise_costs_premiums, 0)+ coalesce(a.jy_supervise_costs_proportion, 0 )) as sxf_settlement,
-        sum(COALESCE(a.jq_other_costs_premiums, 0)+ COALESCE(a.sy_other_costs_premiums, 0)+ coalesce(a.jy_other_costs_premiums, 0 )) as gdf_settlement
+        sum(COALESCE(a.actual_received_amount, 0)) as settlement
         from
         (
         select
         ipi.company_id ,
-        ipi.jq_supervise_costs_premiums,
-        ipi.sy_supervise_costs_premiums,
-        ipi.jy_supervise_costs_proportion,
-        ipi.jq_other_costs_premiums,
-        ipi.sy_other_costs_premiums,
-        ipi.jy_other_costs_premiums,
-        ipi.settlement_status ,
-        ipi.settlement_time
-        from
-        ins_ply_income ipi
+        COALESCE(ins.actual_received_amount, 0) as actual_received_amount
+        from ins_ply_income_invoice_settlement ins
+        inner join ins_ply_income_invoice inc
+        on ins.invoice_id = inc.id
+        AND inc.is_delete = 0
+        inner join ins_ply_income_invoice_link link
+        on link.invoice_id = inc.id
+        AND link.is_delete = 0
+        inner join ins_ply_income ipi
+        on link.income_id = ipi.id
+        AND ipi.is_delete = 0
         <where>
-            ipi.is_delete = 0
-            AND ipi.settlement_status = 1
-            <if test="settledStartDate != null and settledStartDate != ''">
-                AND ipi.settlement_time >= cast( '${settledStartDate}' as datetime)
+            ins.is_delete = 0
+            <if test="settledStartDate != null">
+                AND ins.receive_payment_date >= #{settledStartDate}
             </if>
-            <if test="settledEndDate != null and settledEndDate != ''">
-                AND ipi.settlement_time &lt; cast('${settledEndDate}' as datetime)
+            <if test="settledEndDate != null">
+                AND ins.receive_payment_date &lt; #{settledEndDate}
             </if>
             <if test="agreementType != null and agreementType != ''">
                 AND ipi.agreement_type = #{agreementType}
             </if>
+            <if test="invoiceTypes != null and invoiceTypes.size() > 0">
+                AND inc.invoice_type IN
+                <foreach collection="invoiceTypes" item="invoiceType" open="(" separator="," close=")">
+                    #{invoiceType}
+                </foreach>
+            </if>
         </where>
         ) a
-        group by  a.company_id
+        group by a.company_id
     </select>
     <select id="queryFollowIncome" resultType="com.jzg.commons.entity.finance.dto.InsPlyIncomeDto">
         SELECT