<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: trd
    $Date: 2025-4-25 上午09:30:21
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select (select cc.contract_number
                      from con_contract cc
                     where cc.contract_id = t.contract_id) contract_number,
                   (select hbm.bp_name
                      from hls_bp_master hbm, con_contract cc
                     where hbm.bp_id = cc.bp_id_tenant
                       and cc.contract_id = t.contract_id) bp_name_tenant,
                   (select cc.business_type
                      from con_contract cc
                     where cc.contract_id = t.contract_id) business_type,
                   (select bt.description
                      from hls_business_type bt, con_contract ct
                     where bt.business_type = ct.business_type
                       and ct.contract_id = t.contract_id) as business_type_n,
                   t.sbo_num,
                   t.journal_num,
                   to_char(t.journal_date, 'yyyy/mm/dd') journal_date,
                   (select ga.account_code
                      from gld_accounts ga
                     where ga.account_id = t.account_id) account_code,
                   (select b.description_text
                      from fnd_descriptions b, gld_accounts ga
                     where b.description_id = ga.description_id
                       and ga.account_id = t.account_id
                       and b.ref_table = 'GLD_ACCOUNTS'
                       and b.ref_field = 'DESCRIPTION_ID'
                       and b.language = userenv('LANG')) as description,
                   t.et_fund,
                   t.bp_code_tenant
              from tax_sales_income_temp t
             where t.data_source = 'ET_FUND'
            ]]></bm:query-sql>
        </bm:operation>
     </bm:operations>
     <bm:fields>
     <bm:field name="contract_number"/>
     <bm:field name="bp_name_tenant"/>
     <bm:field name="business_type"/>
     <bm:field name="business_type_n"/>
     <bm:field name="sbo_num"/>
     <bm:field name="et_fund"/>
     <bm:field name="journal_date"/>
     <bm:field name="journal_num"/>
     <bm:field name="account_code"/>
     <bm:field name="description"/>
     <bm:field name="bp_code_tenant"/>
     </bm:fields>
 </bm:model>
