<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    cc.contract_id,
                    TO_CHAR(cus_report_value_pkg.get_overdue_amt(cc.contract_id,sysdate-1,1), 'fm9999,999,999,999,990.00') unreceived_amount_lastday,
                    TO_CHAR(SYSDATE - 1, 'yyyy') yyyy_l,
                    TO_CHAR(SYSDATE - 1, 'MM') mm_l,
                    TO_CHAR(SYSDATE - 1, 'dd') dd_l,
                    to_char(SYSDATE, 'yyyy') yyyy_c,
			       to_char(SYSDATE, 'MM') mm_c,
			       to_char(SYSDATE, 'dd') dd_c,
			        cc.company_id,
(select f.company_full_name from fnd_companies f where f.company_id = cc.company_id) company_id_n
                FROM
                    con_contract cc #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="contract_id = ${@contract_id}"/>
    </bm:query-fields>
</bm:model>
