acr_invoice_create.lwm 9.56 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2
<?xml version="1.0" encoding="UTF-8"?>
<!--
lijingjing's avatar
lijingjing committed
3 4 5 6
    $Author: DJ  
    $Date: 2013-7-4 下午5:06:06  
    $Revision: 1.0  
    $Purpose: 
Spencer Chang's avatar
Spencer Chang committed
7 8 9 10 11
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="record_id"/>
        <bm:field name="cashflow_id"/>
lijingjing's avatar
lijingjing committed
12
        <bm:field name="product_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRODUCT_NAME" prompt="ACR.PRODUCT_NAME"/>
Spencer Chang's avatar
Spencer Chang committed
13
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID"/>
lijingjing's avatar
lijingjing committed
14 15
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NUMBER" prompt="HLS.PROJECT_NUMBER"/>
        <bm:field name="project_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NAME" prompt="HLS.PROJECT_NAME"/>
16
        <bm:field name="product_name_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRODUCT_NAME_DESC" forInsert="false" forUpdate="false"/>
Spencer Chang's avatar
Spencer Chang committed
17
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID"/>
lijingjing's avatar
lijingjing committed
18 19
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="HLS.CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME" prompt="HLS.CONTRACT_NAME"/>
Spencer Chang's avatar
Spencer Chang committed
20
        <bm:field name="invoice_kind" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_KIND"/>
lijingjing's avatar
lijingjing committed
21 22
        <bm:field name="invoice_kind_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_KIND_DESC" prompt="ACR.INVOICE_TYPE"/>
        <bm:field name="due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DUE_AMOUNT" prompt="ACR.DUE_AMOUNT"/>
23 24
        <bm:field name="principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRINCIPAL" prompt="应收本金"/>
        <bm:field name="interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST" prompt="应收利息"/>
lijingjing's avatar
lijingjing committed
25 26 27 28 29 30 31 32 33 34 35 36
        <bm:field name="cf_billing_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="CF_BILLING_AMOUNT" prompt="ACR.BILLING_AMOUNT"/>
        <bm:field name="received_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_AMOUNT" prompt="ACR.RECEIVED_AMOUNT"/>
        <bm:field name="billing_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="BILLING_AMOUNT" prompt="ACR.THIS_BILLING_AMOUNT"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TIMES" prompt="HLS.PERIOD_NUMBER"/>
        <bm:field name="last_received_date" databaseType="DATE" datatype="java.util.Date" physicalName="LAST_RECEIVED_DATE" prompt="ACR.RECEIVED_DATE"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM" prompt="HLS.RECEIVE_PROJECT"/>
        <bm:field name="cf_item_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_ITEM_DESC" prompt="HLS.RECEIVE_PROJECT"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY" prompt="HLS.CURRENCY"/>
        <bm:field name="currency_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_DESC" prompt="HLS.CURRENCY"/>
        <bm:field name="exchange_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="EXCHANGE_RATE" prompt="HLS.EXCHANGE_RATE"/>
        <bm:field name="exchange_rate_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXCHANGE_RATE_TYPE" prompt="HLS.EXCHANGE_RATE_TYPE"/>
        <bm:field name="exchange_rate_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXCHANGE_RATE_TYPE_DESC" prompt="HLS.EXCHANGE_RATE_TYPE_DESC"/>
37
        <bm:field name="billing_object_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
niminmin's avatar
niminmin committed
38 39
        <bm:field name="contract_status" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="cf_status" databaseType="VARCHAR2" datatype="java.lang.String"/>
lizhe's avatar
lizhe committed
40 41 42
        <bm:field name="invoice_kind_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_KIND_TYPE"/>
        <bm:field name="invoice_kind_type_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_KIND_TYPE_N" prompt="发票种类"/>
        <bm:field name="rl_flag"/>
18083's avatar
18083 committed
43 44
        <bm:field name="full_elec_invoice_flag"/>
        <bm:field name="full_elec_invoice_flag_n"/>
45
        <bm:field name="business_type" />
Spencer Chang's avatar
Spencer Chang committed
46 47 48 49
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
lijingjing's avatar
lijingjing committed
50 51 52 53 54 55 56
            	select t.cashflow_id,
				       t.record_id,
				       t.billing_object,
				       (select c.code_value_name
				          from sys_code_values_v c
				         where c.code = 'ACR510_BILL_DETAIL_METHOD'
				           and c.code_value = t.billing_object) as billing_object_desc,
57 58
				         (select m.bp_name
          from hls_bp_master_s_v m
59
         where m.bp_id =t.bp_id) billing_object_name,
60

lijingjing's avatar
lijingjing committed
61
				       t.due_amount,
lizhe's avatar
lizhe committed
62
				       /*-- t.billing_amount,
niminmin's avatar
niminmin committed
63 64 65 66
				       (case when cf.cf_item= 1 and  cf.cf_status='BLOCK' then
				        t.received_amount-nvl(t.cf_billing_amount,0)
				       else
                       t.due_amount-nvl(t.cf_billing_amount,0)
lizhe's avatar
lizhe committed
67 68
                       end )billing_amount,*/
                       t.billing_amount,
lijingjing's avatar
lijingjing committed
69 70 71
				       t.cf_billing_amount,
				       t.received_amount,
				       t.contract_id,
72
				       decode(t.cf_item, 101, 0, cf.principal) principal,
73
                       cf.interest,
lijingjing's avatar
lijingjing committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
				       con.contract_number,
				       con.contract_name,
				       con.project_id,
				       con.project_number,
				       con.project_name,
				       t.invoice_kind,
				       (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'ACR510_INVOICE_KIND'
				           and v.code_value = t.invoice_kind) as invoice_kind_desc,
				       t.currency,
				       (select c.currency_name
						  from gld_currency_vl c
						 where c.currency_code = t.currency) as currency_desc,
				       1 as exchange_rate,
				       'MANUAL' as exchange_rate_type,
				       (select v.rate_type_desc
				          from gld_exchange_rate_type_v v
				         where v.rate_type_code = 'MANUAL') as exchange_rate_type_desc,
				       cf.times,
				       cf.last_received_date,
				       t.cf_item,
				       (select i.description
				          from hls_cashflow_item i
				         where i.cf_item = t.cf_item) as cf_item_desc,
99 100
						decode(t.cf_item,250,'融资租赁挖掘机','融资租赁费') as product_name,
						decode(t.cf_item,250,'融资租赁挖掘机','融资租赁费') as product_name_desc,
niminmin's avatar
niminmin committed
101
				       con.contract_status contract_status,
102 103 104 105 106 107
				       cf.cf_status cf_status,
				       t.invoice_kind_type,
				       (select v.code_value_name
						from sys_code_values_v v
						where v.code = 'ACR512_INVOICE_KIND_TYPE'
						and v.code_value = t.invoice_kind_type) invoice_kind_type_n
lizhe's avatar
lizhe committed
108 109 110 111
                   , case when acr_invoice_pkg.check_rl_cf_flag(con.contract_id,cf.cf_item,cf.times)= 'Y' and
                     acr_invoice_pkg.check_rl_flag(con.contract_id) = 'Y'
                     then
                     'Y'
lizhe's avatar
lizhe committed
112 113 114 115
                      when acr_invoice_pkg.check_rl_cf_flag(con.contract_id,cf.cf_item,cf.times)= 'Y' and
                     acr_invoice_pkg.check_rl_flag(con.contract_id) = 'N'
                     then
                     'N'
lizhe's avatar
lizhe committed
116 117
                     else
                     ''
118
                    end rl_flag,
18083's avatar
18083 committed
119 120 121 122
                    con.business_type,
                    t.full_elec_invoice_flag,
                    (select v.code_value_name value_name from sys_code_values_v v where v.code = 'YES_NO' and v.code_value = t.full_elec_invoice_flag) full_elec_invoice_flag_n

lijingjing's avatar
lijingjing committed
123 124
				  from acr_invoice_create_tmp      t,
				       con_contract_v              con,
125
				       con_contract_cashflow_all_v cf,
niminmin's avatar
niminmin committed
126
                       hls_bp_master t1
lijingjing's avatar
lijingjing committed
127 128 129
				 where t.session_id = ${/session/@session_id}
				   and t.contract_id = con.contract_id
				   and t.cashflow_id = cf.cashflow_id
niminmin's avatar
niminmin committed
130 131
				   and t1.bp_id = t.bp_id
                   order by con.bp_id_agent_level1,t1.bp_id,con.contract_number,cf.times
lijingjing's avatar
lijingjing committed
132
			]]></bm:query-sql>
Spencer Chang's avatar
Spencer Chang committed
133
        </bm:operation>
lijingjing's avatar
lijingjing committed
134

Spencer Chang's avatar
Spencer Chang committed
135 136
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
lijingjing's avatar
lijingjing committed
137 138 139
				begin
				  ACR_INVOICE_PKG.invoiceTmp_update(p_record_id				=> ${@record_id},
						                            p_invoice_kind          => ${@invoice_kind},
140
													p_invoice_kind_type     => ${@invoice_kind_type},
lijingjing's avatar
lijingjing committed
141 142 143 144 145
						                            p_billing_amount  		=> ${@billing_amount},
						                            p_product_name          => ${@product_name},
						                            p_user_id			  	=> ${/session/@user_id});
				end;
			]]></bm:update-sql>
Spencer Chang's avatar
Spencer Chang committed
146 147 148
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
lijingjing's avatar
lijingjing committed
149 150 151 152 153 154 155 156 157 158
				begin
					ACR_INVOICE_PKG.create_invoice(p_session_id           => ${/session/@session_id},
						                           p_company_id           => ${@company_id},
						                           p_group_billing_method => ${@group_billing_method},
						                           p_invoice_date         => to_date(${@invoice_date},'yyyy-mm-dd'),
						                           p_accounting_date      => to_date(${@accounting_date},'yyyy-mm-dd'),
						                           p_user_id			  => ${/session/@user_id},
						                           p_role_id			  => ${/session/@role_id});
				end;
			]]></bm:update-sql>
Spencer Chang's avatar
Spencer Chang committed
159 160 161
        </bm:operation>
    </bm:operations>
</bm:model>