<?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
                    rownum sequence,
                    cc.contract_number,
                    pp.project_name,
                    ca.cf_item_name,
                    (SELECT bm.bp_name FROM hls_bp_master bm WHERE bm.bp_id= cc.bp_id_tenant
                    ) bp_name,
                    ca.due_date,
                    cwo.session_id,
                    cwo.write_off_type,
                    cwo.transaction_category,
                    cwo.transaction_type,
                    cwo.write_off_date,
                    cwo.write_off_due_amount,
                    cwo.write_off_principal,
                    cwo.write_off_interest,
                    cwo.write_off_due_amount_cny,
                    cwo.write_off_principal_cny,
                    cwo.write_off_interest_cny,
                    cwo.exchange_rate,
                    cwo.company_id,
                    cwo.document_category,
                    cwo.document_id,
                    cwo.document_line_id,
                    cwo.description,
                    cwo.creation_date,
                    cwo.created_by,
                    cwo.last_update_date,
                    cwo.last_updated_by,
                    cwo.subsequent_csh_bp_id,
                    cwo.sub_write_off_type,
                    cwo.opposite_doc_category,
                    cwo.opposite_doc_type,
                    cwo.opposite_doc_id,
                    cwo.opposite_doc_line_id,
                    cwo.opposite_doc_detail_id,
                    cwo.opposite_write_off_amount,
                    cwo.transaction_id,
                    cwo.temp_id,
                    cwo.bp_id,
                    cwo.year_flag,
                    cwo.quarter_flag,
                    cwo.month_flag,
                    cwo.transfer_type,
                    cwo.wfl_instance_id,
                    cwo.risk_in_dec,
                    cwo.write_off_id,
                    ca.cashflow_id,
                    ca.due_amount,
                    ca.principal,
                    ca.interest,
                    ca.times,
                    ca.received_amount,
                    ca.received_principal,
                    ca.received_interest,
                    ca.penalty,
                    ca.penalty_cashflow_id,
                    ca.unreceived_amount,
                    ca.unreceived_principal,
                    ca.unreceived_interest,
                    ca.bp_id_tenant bp_id,
                    ca.write_off_order,
                    ca.write_off_order100,
                    ca.write_off_order101,
                    ca.cf_item,
                    ca.cf_type,
                    null write_off_penalty,
                    null penalty_tmp_id
                FROM
                    csh_write_off_temp cwo,
                    con_contract cc,
                    prj_project pp,
                    CON_CONTRACT_CASHFLOW_V ca
                WHERE
                    cwo.transaction_id   = ${@transaction_id} AND
                    cwo.write_off_type  IN ('RECEIPT_CREDIT','ADVANCE_RECEIPT_CREDIT','DEPOSIT_CREDIT','RISK_CREDIT') AND
                    cwo.document_id      = cc.contract_id AND
                    cc.project_id        =pp.project_id(+) AND
                    cwo.document_line_id = ca.cashflow_id
            ]]></bm:query-sql>
            <bm:parameters>
                <bm:parameter name="transaction_id"/>
            </bm:parameters>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            begin
        		delete from csh_write_off_temp  cwo where cwo.temp_id = ${@temp_id};
        	end;	
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
