create view vi_chargebackvouchertotal as SELECT LRP.ID                                                                                               AS ID,
       LSC.SUBJECTS_CODE                                                                                    AS SUBJECTS_CODE,
       LRI.OWN_NUMBER                                                                                       AS OWN_NUMBER,
       LRP.COLLECT_STATUS                                                                                   AS COLLECT_STATUS,
       OI.OWN_NAME                                                                                          AS OWN_NAME,
       LRI.SPARE_BATCH_NO                                                                                   AS SPARE_BATCH_NO,
       LRI.SPARE_BATCH_NO                                                                                   AS SPARE_BATCH_NO_DATA,
       (CASE WHEN (LRP.COLLECT_STATUS = '批量收款') THEN '广州银联' ELSE '其它' END)                                  AS CHANNEL,
       LRI.HIRE_DATE                                                                                        AS HIRE_DATE,
       VSS.ACHIEVED_DATE                                                                                    AS ACHIEVED_DATE,
       LRI.OWN_BANK                                                                                         AS OWN_BANK,
       (sum(LRI.RENT) + sum(LRI.PENALTY))                                                                   AS CHARGEBACK_MONEY_S,
       count(LRI.CONTRACT_ID)                                                                               AS CHARGEBACK_QTY_S,
       (CASE WHEN (isnull(VS.CHARGEBACK_STATUS) OR (VS.CHARGEBACK_STATUS = '')) THEN '未核销' ELSE '核销成功' END) AS CHARGEBACK_STATUS
FROM ((((((APZL.LC_RENT_PLAN LRP LEFT JOIN APZL.LC_RENT_INCOME LRI ON (((LRI.CONTRACT_ID = LRP.CONTRACT_ID) AND (LRI.PLAN_LIST = LRP.PLAN_LIST)))) LEFT JOIN APZL.OWN_ACCOUNT OA ON ((LRI.OWN_NUMBER = OA.ACC_NUMBER))) LEFT JOIN APZL.OWN_INFO OI ON ((OA.OWN_ID = OI.OWN_NUMBER))) LEFT JOIN APZL.VERIFICATIONSPARE VS ON ((VS.SPARE_BATCH_NO = convert(LRI.SPARE_BATCH_NO USING UTF8)))) LEFT JOIN APZL.LV_STACTS_CONFIG LSC ON ((LSC.ID = OA.ACC_TITLE)))
LEFT JOIN APZL.VERIFICATIONSPARE VSS ON ((VSS.SPARE_BATCH_NO = convert(LRI.SPARE_BATCH_NO USING UTF8))))
WHERE ((LRP.COLLECT_STATUS IN ('手工收款', '批量收款', '网银收款')) AND ((LRI.EBANK_NUMBER = '') OR isnull(LRI.EBANK_NUMBER)))
GROUP BY LRI.HIRE_DATE, LRI.OWN_NUMBER, LRP.COLLECT_STATUS;

-- comment on column vi_chargebackvouchertotal.id not supported: 标识

-- comment on column vi_chargebackvouchertotal.subjects_code not supported: 科目编号

-- comment on column vi_chargebackvouchertotal.own_number not supported: 本方银行帐号

-- comment on column vi_chargebackvouchertotal.COLLECT_STATUS not supported: 收款状态

-- comment on column vi_chargebackvouchertotal.OWN_NAME not supported: 出租人

-- comment on column vi_chargebackvouchertotal.SPARE_BATCH_NO not supported: 扣款批次号

-- comment on column vi_chargebackvouchertotal.SPARE_BATCH_NO_DATA not supported: 扣款批次号

-- comment on column vi_chargebackvouchertotal.HIRE_DATE not supported: 核销日期

-- comment on column vi_chargebackvouchertotal.OWN_BANK not supported: 本方银行

