acr_invoice_reverse.lwm 6.33 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-7-18 上午09:32:02  
    $Revision: 1.0  
    $Purpose: 
-->
lijingjing's avatar
lijingjing committed
8

lijingjing's avatar
lijingjing committed
9 10


11
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
Spencer Chang's avatar
Spencer Chang committed
12 13 14
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
               Select t.invoice_apply_id,
                      t.invoice_apply_num,
                      to_char(t.invoice_apply_date, 'yyyy-mm-dd') invoice_apply_date,
                      t.invoice_apply_user,
                      (Select su.description
                       From sys_user su
                       Where su.user_id = t.invoice_apply_user) invoice_apply_user_n,
                      t.wfl_instance_id,
                      t.wfl_apply_status,
                      (Select v.code_value_name
                       From sys_code_values_v v
                       Where v.code = 'WFL_STATUS'
                         And v.code_value = t.wfl_apply_status) wfl_apply_status_n,
                      nvl((Select nvl(Sum(ah.total_amount), 0)
                           From acr_invoice_hd_wfl ah
                           Where ah.invoice_apply_id = t.invoice_apply_id),
                          0) total_amount,
                      nvl((Select nvl(Sum(ah.tax_amount), 0)
                           From acr_invoice_hd_wfl ah
                           Where ah.invoice_apply_id = t.invoice_apply_id),
                          0) tax_amount,
                      nvl((Select nvl(Sum(nvl(ah.total_amount, 0) - nvl(ah.tax_amount, 0)),
                                      0)
                           From acr_invoice_hd_wfl ah
                           Where ah.invoice_apply_id = t.invoice_apply_id),
                          0) net_amount,
                      t.creation_date,
                      t.created_by,
                      t.last_update_date,
                      t.last_updated_by,
                      t.note,
                      t.ref_v01,
                      t.ref_v02,
                      t.ref_v03,
                      t.ref_v04,
                      t.ref_v05,
                      t.ref_n01,
                      t.ref_n02,
                      t.ref_n03,
                      t.ref_n04,
                      t.ref_n05,
                      t.ref_d01,
                      t.ref_d02,
                      t.ref_d03,
                      t.ref_d04,
                      t.ref_d05,
                      t.apply_mode,
                      t.reverse_method,
                      (Select v.code_value_name
                       From sys_code_values_v v
                       Where v.code = 'REVERSE_METHOD'
                         And v.code_value = t.reverse_method
                         and v.code_enabled_flag = 'Y'
                         and v.code_value_enabled_flag = 'Y') As reverse_method_n,
                      (Select  ahd.vat_interface_status
                       From  acr_invoice_hd ahd,acr_invoice_hd_wfl ahdw
                       Where  ahd.invoice_hd_id=ahdw.invoice_hd_id
                         and ahdw.invoice_apply_id=t.invoice_apply_id
                         and rownum=1) vat_interface_status,
                      (Select v.code_value_name
                       From sys_code_values_v v, acr_invoice_hd ahd,acr_invoice_hd_wfl ahdw
                       Where v.code = 'ACR515_VAT_INTERFACE_STATUS'
                         And v.code_value = ahd.vat_interface_status
                         and v.code_enabled_flag = 'Y'
                         and v.code_value_enabled_flag = 'Y'
                          and ahd.invoice_hd_id=ahdw.invoice_hd_id
                          and ahdw.invoice_apply_id=t.invoice_apply_id
                          and rownum=1) As vat_interface_status_n,
                      decode((select count(1)
                       from acr_invoice_hd ah, acr_invoice_hd_wfl ahw
                       where ah.invoice_hd_id = ahw.invoice_hd_id
                         and ahw.invoice_apply_id = t.invoice_apply_id
                         and nvl(ah.reversed_flag, 'N') = 'I'),0,'N','Y') reversing_flag
               From acr_invoice_apply t
                               #WHERE_CLAUSE#
               order by t.invoice_apply_id desc
Spencer Chang's avatar
Spencer Chang committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    acr_invoice_pkg.reverse_invoice(p_invoice_hd_id 		=> ${@invoice_hd_id},
								                    p_reverse_date 			=> to_date(${@reverse_date},'yyyy-mm-dd'), 
								                    p_vat_red_notice_num	=> ${@vat_red_notice_num},
								                    p_user_id 				=> ${/session/@user_id}, 
								                    p_role_id 				=> ${/session/@role_id});
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
106 107 108 109 110 111 112 113 114 115
        <bm:query-field name="invoice_apply_num"
                        queryExpression="t.invoice_apply_num like &apos;%&apos;||${@invoice_apply_num}||&apos;%&apos;"/>
        <bm:query-field name="invoice_apply_date"
                        queryExpression="trunc(t.invoice_apply_date) = to_date(${@invoice_apply_date}, 'yyyy-mm-dd')"/>
        <bm:query-field name="invoice_apply_user_n" queryExpression="t.invoice_apply_user = ${@invoice_apply_user}"/>
        <bm:query-field name="wfl_apply_status_n" queryExpression="t.wfl_apply_status = ${@wfl_apply_status}"/>
        <bm:query-field name="vat_interface_status_n"
                        queryExpression="t.vat_interface_status = ${@vat_interface_status}"/>
        <bm:query-field name="invoice_apply_id" queryExpression="t.invoice_apply_id = ${@invoice_apply_id}"/>
        <bm:query-field name="apply_mode" queryExpression="nvl(t.apply_mode, &apos;APPLY&apos;) = ${@apply_mode}"/>
Spencer Chang's avatar
Spencer Chang committed
116 117
    </bm:query-fields>
    <bm:data-filters>
118 119 120 121 122 123
        <bm:data-filter enforceOperations="query" expression="t.wfl_apply_status = &apos;APPROVED&apos;"/>
        <bm:data-filter enforceOperations="query" expression="exists (select 1
                             from acr_invoice_hd ah, acr_invoice_hd_wfl ahw
                             where ah.invoice_hd_id = ahw.invoice_hd_id
                               and ahw.invoice_apply_id = t.invoice_apply_id
                               and nvl(ah.reversed_flag, 'N') = 'N')" />
Spencer Chang's avatar
Spencer Chang committed
124 125
    </bm:data-filters>
</bm:model>