<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    SELECT t1.contract_status_n,
       t1.con_maintain_flag,
       t1.project_number,
       t1.project_document_type,
       t1.bp_class,
       t1.bp_class_n,
       t1.version_number,
       t1.owner,
       t1.closed_date,
       t1.contract_creation_date,
       t1.wfl_instance_id,
       t1.submit_date_detail,
       t1.archive_status,
       t1.archive_status_n,
       t1.large_area,
       t1.content_type,
       t1.content_type_n,
       t1.sys_level,
       t1.bs_level,
       t1.lease_execution_date,
       t1.agent_extra_nam,
       t1.data_class,
       t1.data_class_n,
       t1.contract_id,
       t1.calc_session_id,
       t1.contract_number,
       t1.contract_name,
       t1.business_type,
       t1.district,
       t1.finance_amount,
       t1.province,
       t1.province_n,
       t1.city,
       t1.city_n,
       t1.departing_date,
       t1.departed_date,
       t1.depart_status,
       t1.depart_status_n,
       t1.district_n,
       t1.business_type_n,
       t1.document_type,
       t1.prj_document_type,
       t1.document_type_n,
       t1.document_category,
       t1.document_category_n,
       t1.project_id,
       t1.project_id_c,
       t1.project_id_n,
       t1.company_id,
       t1.company_id_n,
       t1.spv_company_id,
       t1.spv_company_code,
       t1.spv_company_id_n,
       t1.lease_organization,
       t1.lease_organization_n,
       t1.lease_channel,
       t1.prj_lease_channel,
       t1.special_permit_flag,
       t1.lease_channel_n,
       t1.division,
       t1.division_n,
       t1.bp_id_tenant,
       t1.bp_code,
       t1.bp_id_tenant_n,
       t1.bp_name,
       t1.bp_id_tenant_name,
       t1.bp_id_agent_level1,
       t1.bp_id_agent_level1_n,
       t1.bp_id_agent_level2,
       t1.bp_id_agent_level2_n,
       t1.bp_id_agent_level3,
       t1.bp_id_agent_level3_n,
       t1.owner_user_id,
       t1.owner_user_id_n,
       t1.employee_id,
       t1.employee_id_n,
       t1.unit_id,
       t1.unit_id_n,
       t1.employee_id_of_manager,
       t1.employee_id_of_manager_n,
       t1.factoring_type,
       t1.description,
       t1.price_list,
       t1.price_list_n,
       t1.calc_method,
       t1.inception_of_lease,
       t1.contract_status
  FROM CON_CONTRACT_CAL_EASY_LV t1
 WHERE t1.data_class ='NORMAL'
   AND t1.document_type = 'CARCON'
   AND t1.document_type_n LIKE '汽车类合同'
   AND t1.company_id IN
       (SELECT company_id
          FROM fnd_companies
         START WITH company_id = 1
        CONNECT BY PRIOR company_id = parent_biz_company_id)
   AND ('Y' = 'Y' AND EXISTS
        (SELECT
          1
           FROM aut_trx_user_authorize a1, aut_owner_user_authorize a2
          WHERE a1.trx_category = 'CONTRACT'
            AND a1.trx_id = t1.contract_id
            AND trunc(SYSDATE) BETWEEN a1.start_date AND
                nvl(a1.end_date, trunc(SYSDATE))
            AND a1.user_id = a2.owner_user_id
            AND a1.trx_category = a2.trx_category
            AND a2.authorized_user_id =1
            AND trunc(SYSDATE) BETWEEN a2.start_date AND
                nvl(a2.end_date, trunc(SYSDATE))))

            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
