<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Harry
    $Date: 2018-8-1 下午4:45:08
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:f="leaf.database.features"
          xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CSH_RECEIPT_BANK_ACCOUNT">
    <bm:fields>
        <bm:field name="receipt_account_id"/>
        <bm:field name="bank_account_number"/>
        <bm:field name="status"/>
        <bm:field name="status_n"
                  expression="(select v.code_value_name from sys_code_values_v v where v.code = &apos;CSH_BANK_ACCOUNT_STATUS&apos; and v.code_value =t1.status)"
                  forInsert="false" forUpdate="false"/>
        <bm:field name="vender_bp_id"/>
        <bm:field name="vender_bp_id_n"
                  expression="(select m.bp_name||'+'||m.bp_code from hls_bp_master m where m.bp_id = t1.vender_bp_id)" forInsert="false"
                  forUpdate="false"/>
        <bm:field name="bp_id"/>
        <bm:field name="bp_code" expression="(select m.bp_code from hls_bp_master m where m.bp_id = t1.bp_id)"
                  forInsert="false" forUpdate="false"/>
        <bm:field name="bp_name" expression="(Select m.bp_name From hls_bp_master m Where m.bp_id = t1.bp_id)"
                  forInsert="false" forUpdate="false"/>
        <bm:field name="id_card_number"/>
        <bm:field name="bank_account_name"/>
        <bm:field name="bank_name"/>
        <bm:field name="usage"/>
        <bm:field name="usage_n" expression="(Select v.code_value_name From sys_code_values_v v Where v.code = 'BANK_CARD_USAGE' And v.code_value = t1.usage And v.code_value_enabled_flag = 'Y')"/>
        <bm:field name="upload_date" datatype="date" expression="(select t.last_update_date from csh_receipt_bank_account t where t.receipt_account_id = t1.receipt_account_id)"/>
        <bm:field name="app_bp_name"/>
        <bm:field name="app_id_card"/>
        <bm:field name="app_confirm_flag"/>
        <bm:field name="app_confirm_flag_n" expression="(Select v.code_value_name From sys_code_values_v v Where v.code = 'YES_NO' And v.code_value = t1.app_confirm_flag And v.code_value_enabled_flag = 'Y')"/>

    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="receipt_account_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
                BEGIN
                    ${@v_message} := csh_bank_account_pkg.receipt_bank_account_import(p_header_id => ${@header_id}, p_user_id => ${/session/@user_id});
                END;
            ]]></bm:update-sql>
            <bm:parameters>
                <bm:parameter name="v_message" output="true" outputPath="@v_message"/>
            </bm:parameters>
        </bm:operation>


        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                      Update csh_receipt_bank_account t
                      Set t.status           = '04',
                          t.last_updated_by  = ${/session/@user_id},
                          t.last_update_date = Sysdate
                    Where t.receipt_account_id = ${@receipt_account_id};

                END;
            ]]></bm:update-sql>
        </bm:operation>


    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="bank_account_number"
                        queryExpression="t1.bank_account_number like &apos;%&apos;||${@bank_account_number}||&apos;%&apos;"/>
        <bm:query-field name="status" queryExpression="t1.status = ${@status}"/>
        <bm:query-field name="vender_bp_id" queryExpression="t1.vender_bp_id = ${@vender_bp_id}"/>
        <bm:query-field name="bp_id" queryExpression="t1.bp_id = ${@bp_id}"/>
    </bm:query-fields>
</bm:model>
