<?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.times,
                   t.diff_unfinance_income,
                   to_char(t.due_date, 'yyyy/mm/dd') due_date,
                   to_char(t.last_received_date, 'yyyy/mm/dd') last_received_date,
                   to_char(t.last_write_off_date, 'yyyy/mm/dd') last_write_off_date,
                   to_char(t.calc_start_date, 'yyyy/mm/dd') calc_start_date,
                   to_char(t.calc_end_date, 'yyyy/mm/dd') calc_end_date
              from tax_sales_income_temp t
             where t.data_source = 'DATABASE_INCOME'
                 ]]></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="times"/>
    <bm:field name="diff_unfinance_income"/>
    <bm:field name="due_date"/>
    <bm:field name="last_received_date"/>
    <bm:field name="last_write_off_date"/>
    <bm:field name="calc_start_date"/>
    <bm:field name="calc_end_date"/>
    </bm:fields>
  </bm:model>
