<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            SELECT (SELECT reverse(substr(reverse(t1.DOCUMENT_NUMBER),1,INSTR(reverse(t1.DOCUMENT_NUMBER),'-') - 1)) FROM DUAL) req_num,
			       t1.LOAN_CONTRACT_ID,
			       t1.LOAN_CONTRACT_NUMBER,
			       t1.LOAN_CONTRACT_NAME,
			       t1.DOCUMENT_STATUS,
			       t1.DOCUMENT_NUMBER,  -- 提款编号
			       t1.BANK_ACCOUNT_ID,
			       (select cbb.bank_branch_name
                      from csh_bank_account cba,csh_bank_branch cbb
                     where cba.bank_account_id = t1.bank_account_id
                       and cba.bank_branch_id = cbb.bank_branch_id) bank_branch_name,
			       t1.BANK_ACCOUNT_ID_N,-- 收款账号
			       '￥'||to_char(t1.LEASE_ITEM_AMOUNT,'FM999,999,999,999,990.90') lease_item_amount,-- 金额
			       change_number_to_rmb(t1.LEASE_ITEM_AMOUNT) lease_item_amount_n,
			       t1.LEASE_START_DATE, --提款日期
			       t1.LEASE_TIMES,
			       t1.ANNUAL_PAY_TIMES,
			       t1.ANNUAL_PAY_TIMES_N,
			       t1.INT_RATE,
			       t1.CURRENCY_N,
			       t1.LEASE_END_DATE,
			       t1.HD_USER_COL_N18,-- 付息日
			       t1.INSIDE_OR_OUTSIDE,
			       t1.INSIDE_OR_OUTSIDE_N,
			       t1.WAY_OF_INCREASING_TRUST,
			       t1.DOCUMENT_TYPE,
			       t1.LOAN_CON_BP,
			       t1.LOAN_CON_BP_NAME,    -- 债权人
			       t1.INT_RATE_N,
			       t1.DOCUMENT_ID,
			       t1.CALC_SESSION_ID,
			       t1.TEXT,                -- 备注
			       t1.QUOTATION_ID
			  FROM tre_loan_con_quotaion_lv t1
			 WHERE t1.loan_contract_id = ${@loan_contract_id}
			   AND t1.QUOTATION_ID = ${@quotation_id}
			   ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
