<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: lpc 9874 
    $Date:  
    $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
                        NVL(SUM(ccc.principal), 0) - NVL(SUM(ccc.received_principal), 0)
                    FROM
                        con_contract_cashflow ccc
                    WHERE
                        ccc.contract_id IN
                        (SELECT
                            contract_id
                        FROM
                            con_contract cc
                        WHERE
                            cc.bp_id_tenant    = pp.bp_id_tenant AND
                            cc.data_class      = 'NORMAL' AND
                            cc.contract_status IN ('INCEPT','PENDING')
                        ) AND
                        ccc.cf_status = 'RELEASE' AND
                        ccc.cf_item   = 1
                    ) risk_open,
                    get_write_off_amount(pp.project_id) write_off_amount,
                    pp.return_opinion
                FROM
                    prj_project pp
                WHERE
                    pp.project_id = ${/parameter/@project_id}
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    UPDATE
                        prj_project
                    SET
                        return_opinion = ${@return_opinion}
                    WHERE
                        project_id = ${@project_id};
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
