<?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
              sum(ACTUAL_PRICE) actual_price_total
            from (select
                    cti.STORAGE_DATE,
                    cti.AGENT_NAME,
                    cti.CNTRT_NO CONTRACT_NUMBER,
                    cti.BP_NAME,
                    cti.MACHINE_NUMBER,
                    cti.PATTERN,
                    1                                MACHINE_COUNTS,
                    cti.STORAGE_AMOUNT,
                    cti.ACTUAL_PRICE,
                    cti.SALES_OPERATEION_DATE,
                    substr(cti.CNTRT_NO, 6, 1) ticket_type,
                    cti.ACCOUNT_NOTES,
                    cti.PHONE_CNO
                  from CON_TRAILER_INFO cti
                              #WHERE_CLAUSE#

                 ) t1
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="actual_price_total" databaseType="NUMBER" datatype="java.lang.Double"/>
    </bm:fields>

    <bm:query-fields>
        <bm:query-field name="agent_name" queryExpression="cti.agent_name like ${@agent_name}"/>
        <bm:query-field name="contract_number" queryExpression="cti.cntrt_no like ${@cntrt_no}"/>
        <bm:query-field name="bp_name" queryExpression="cti.bp_name like ${@bp_name}"/>
        <bm:query-field name="machine_number" queryExpression="cti.machine_number like ${@machine_number}"/>
        <bm:query-field name="pattern" queryExpression="cti.pattern like ${@pattern}"/>
        <bm:query-field name="phone_cno" queryExpression="cti.phone_cno like ${@phone_cno}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression=" 1 = 1
                        and cti.CREATE_SALES_JE_FLAG = &apos;Y&apos;
                        and (cti.SEC_CAR_REVERSE_FLAG != &apos;Y&apos;
                             or cti.SEC_CAR_REVERSE_FLAG is null)
                        and (cti.SEC_CAR_REVERSE_SALES_FLAG != &apos;Y&apos;
                             or cti.SEC_CAR_REVERSE_SALES_FLAG is null)"/>
    </bm:data-filters>

</bm:model>
