<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
     	SELECT fnd_code_rule_pkg.get_rule_next_auto_num(p_document_category => 'GPS_ZR_APPCODE',
		                                                p_document_type     => 'GPS_ZR_APPCODE_DOC',
		                                                p_company_id        => ${/session/@company_id},
		                                                p_operation_unit_id => null,
		                                                p_operation_date    => sysdate,
		                                                p_created_by        => ${/session/@user_id}) appcode,
					     
					      '4F500000-4C4F-0200-8AF0-08D3209FA2B8' productid,
					       null producttype,
					       fc.city_code districtcode,
					       acg.install_address installadd,
					       to_char(acg.install_date,'yyyy-mm-dd hh24:mm:ss') installtime,
					       ahbm.bp_name shopname,
					       ahbm.CONTACT_PERSON linkman,
					       ahbm.PHONE_EXTRA linkphone,
					       hbm.bp_name username,
					       hbm.cell_phone userphone,
					       mv.description cartype,
					       t.current_licence platenumber,
					       t.Item_Frame_Number vin,
					       t.COLOR_OF_APPREARANCE color,
					       to_char(t.guide_price) carprice,
					       to_char(cc.finance_amount) loanamount,
					       to_char(cc.Lease_Times) creditperiod,
					       to_char(1) num,
					       null remark
					  FROM con_contract_lv         cc,
					       con_contract_lease_item t,
					       hls_car_model_vl        mv,
					       hls_bp_master_lv        hbm,
					       hls_bp_master_lv        ahbm,
					      fnd_city                fc,
					      ast_car_gps             acg ,
					       con_contract_bp cbp
					 WHERE cc.contract_id = t.contract_id
					 AND t.model_id=mv.model_id
					   AND cc.bp_id_tenant = hbm.bp_id
					   and ahbm.bp_id = cbp.bp_id
					   AND fc.city_id = ahbm.city_sp
					   and cc.contract_id = acg.contract_id
					   and cbp.bp_category = 'AGENT'
					   and cc.contract_id = cbp.contract_id
					   AND cc.contract_id = ${@contract_id}
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <!--  (SELECT
                        sc.code_value_name
                    FROM
                        sys_code_values_v sc
                    WHERE
                        sc.code       = 'GH_ZR_PRODUCT' AND
                        sc.code_value = acg.zr_product_id
                    )  productid, -->
</bm:model>
