<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: leaf Generator  
    $Date: Mon Sep 16 09:55:25 CST 2019  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:f="leaf.database.features" alias="t1" baseTable="CSH_TRANSACTION_PLAN">
    <bm:fields>
        <bm:field name="plan_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PLAN_ID" prompt="CSH_TRANSACTION_PLAN.PLAN_ID"/>
        <bm:field name="transaction_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TRANSACTION_ID" prompt="CSH_TRANSACTION_PLAN.TRANSACTION_ID"/>
        <bm:field name="write_off_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WRITE_OFF_TYPE" prompt="CSH_TRANSACTION_PLAN.WRITE_OFF_TYPE"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID" prompt="CSH_TRANSACTION_PLAN.BP_ID"/>
        <bm:field name="bp_agent_name" expression="(select bp_name from hls_bp_master where bp_id = t1.bp_id)" prompt="代理店" forInsert="false" forceUpdate="false"/>
        <bm:field name="bp_name" expression="(select bp_name from hls_bp_master where bp_id = t1.bp_id)" prompt="商业伙伴" forInsert="false" forceUpdate="false"/>
        <bm:field name="write_off_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_AMOUNT" prompt="核销金额"/>
        <bm:field name="write_off_date" databaseType="DATE" datatype="java.util.Date" physicalName="WRITE_OFF_DATE" prompt="CSH_TRANSACTION_PLAN.WRITE_OFF_DATE"/>
        <bm:field name="company_id" databaseType="NUMBER" databasetype="java.lang.Long" physicalName="COMPANY_ID" prompt="CSH_TRANSACTION_PLAN.COMPANY_ID"/>
        <bm:field name="create_wf_flag_desc" expression="(decode(t1.create_wf_flag,'Y','是','否'))"/>
        <bm:field name="create_wf_flag"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="create_wf_flag" queryOperator="="/>
    </bm:query-fields>
    <bm:primary-key>
        <bm:pk-field name="plan_id"/>
    </bm:primary-key>
    <bm:features>
        <o:sequence-pk sequenceName="csh_transaction_plan_s"/>
        <f:standard-who xmlns:f="leaf.database.features"/>
    </bm:features>
    <bm:data-filters>
        <bm:data-filter name="query" expression="(t1.transaction_id=${@transaction_id} and t1.company_id=${/session/@company_id} and t1.write_off_type = ${@write_off_type})"/>
        <bm:data-filter name="query" expression="(nvl(t1.create_wf_flag,'N') = DECODE((select write_off_flag from csh_transaction where transaction_id = t1.transaction_id),'FULL','Y','N'))" />
    </bm:data-filters>
</bm:model>