1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: syj
$Date: 2015年7月27日12:04:24
$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
*
FROM
(SELECT
c.contract_id,
cc.cashflow_id,
c.contract_number,
m.bp_name bp_name,
cc.times,
cc.cf_item,
(select hci.description from hls_cashflow_item hci
where hci.cf_item=cc.cf_item) cf_item_n,
cc.due_date,
cc.calc_date,
(select max(ccc.due_date) from con_contract_cashflow ccc
where ccc.contract_id = cc.contract_id
and ccc.cf_item=1
and ccc.cf_direction='INFLOW'
and ccc.cf_status='RELEASE') lease_end_date,
cc.outstanding_prin_tax_incld,
cc.outstanding_rental_tax_incld,
cc.due_amount,
cc.net_due_amount,
cc.vat_due_amount,
cc.principal,
cc.net_principal,
cc.vat_principal,
cc.interest,
cc.vat_interest,
cc.net_interest,
cc.cf_direction,
(SELECT
i.contact_person
FROM
hls_bp_master_contact_info i
WHERE
i.position = 'CP' AND
i.bp_id = m.bp_id AND
rownum = 1
) contact_person,
(SELECT
i.cell_phone
FROM
hls_bp_master_contact_info i
WHERE
i.position = 'CP' AND
i.bp_id = m.bp_id AND
rownum = 1
) cell_phone,
(SELECT
i.email
FROM
hls_bp_master_contact_info i
WHERE
i.position = 'CP' AND
i.bp_id = m.bp_id AND
rownum = 1
) email,
(SELECT
i.contact_person
FROM
hls_bp_master_contact_info i
WHERE
i.position = 'FM' AND
i.bp_id = m.bp_id AND
rownum = 1
) contact_person_fm,
(SELECT
i.cell_phone
FROM
hls_bp_master_contact_info i
WHERE
i.position = 'FM' AND
i.bp_id = m.bp_id AND
rownum = 1
) cell_phone_fm,
(SELECT
v.province_name
|| v.city_name
|| v.district_name
|| v.address
FROM
hls_bp_master_address_v v
WHERE
v.bp_id = c.bp_id_tenant AND
v.enabled_flag = 'Y' AND
v.address_type = 'DOC_SENT_ADDRESS'
) address,
(SELECT
v.zipcode
FROM
hls_bp_master_address_v v
WHERE
v.bp_id = c.bp_id_tenant AND
v.enabled_flag = 'Y' AND
v.address_type = 'DOC_SENT_ADDRESS'
) zipcode,
e.employee_id,
e.name employee_manager,
c.lease_organization,
(SELECT
o.description
FROM
hls_lease_organization o
WHERE
o.lease_organization = c.lease_organization
) lease_organization_desc,
cc.write_off_flag,
(SELECT
t1.code_value_name
FROM
sys_code_values_v t1
WHERE
t1.code = 'CON_PENALTY_WRITE_OFF_FLAG' AND
t1.code_enabled_flag = 'Y' AND
t1.code_value = cc.write_off_flag
) write_off_flag_desc,
--增值税
cc.ln_user_col_n20,
c.bank_account_id,
(SELECT
ct.bank_account_num
FROM
csh_bank_account ct
WHERE
ct.bank_account_id = c.bank_account_id
) bank_account_id_n,
SUBSTR(c.contract_number, 1, INSTR(c.contract_number, '-') - 1) contract_number_substr,
c.hn_industry_classification,
(SELECT
vv.code_value_name
FROM
sys_code_values_v vv
WHERE
vv.code = 'HN_INDUSTRY_CLASSIFICATION' AND
vv.code_value = c.hn_industry_classification
) hn_industry_classification_n,
(SELECT
ccc.due_amount
FROM
con_contract_cashflow ccc
WHERE
ccc.contract_id = c.contract_id AND
ccc.cf_item = 0 AND
ccc.times = 0
) sum_principal,
c.lease_form,
(SELECT
vv.code_value_name
FROM
sys_code_values_v vv
WHERE
vv.code = 'LEASE_FORM' AND
vv.code_value = c.lease_form
) lease_form_n,
sdic_report_pkg.get_cashflow_bank_account_num(p_cashflow_id => cc.cashflow_id) bank_account_num,
sdic_report_pkg.get_cashflow_bank_name(p_cashflow_id => cc.cashflow_id) bank_name,
c.annual_pay_times,
(SELECT
v.code_value_name
FROM
sys_code_values_v v
WHERE
v.code = 'HLS500_ANNUAL_PAY_TIMES' AND
v.code_value = c.annual_pay_times
)
|| '付' annual_pay_times_n,
sdic_report_pkg.get_cashflow_payment_method(p_cashflow_id => cc.cashflow_id) csh_payment_method_n,
NVL(
(SELECT
ccc.net_due_amount
FROM
con_contract_cashflow ccc
WHERE
ccc.contract_id = cc.contract_id AND
ccc.times = cc.times AND
ccc.cf_item = 3
), 0) net_lease_charge,
NVL(
(SELECT
ccc.vat_due_amount
FROM
con_contract_cashflow ccc
WHERE
ccc.contract_id = cc.contract_id AND
ccc.times = cc.times AND
ccc.cf_item = 3
), 0) vat_lease_charge,
NVL(
(SELECT
ccc.due_amount
FROM
con_contract_cashflow ccc
WHERE
ccc.contract_id = cc.contract_id AND
ccc.times = cc.times AND
ccc.cf_item = 9
), 0) penalty_amount,
c.adjust_rate_type,
(SELECT
ar.code_value_name
FROM
sys_code_values_v ar
WHERE
ar.code = 'ADJUST_RATE_TYPE' AND
ar.code_value = c.adjust_rate_type
) adjust_rate_type_n,
c.flt_next_adj_date,
sdic_report_pkg.get_con_cashflow_adjust_flag(p_cashflow_id => cc.cashflow_id, p_type => 1) adjust_flag,
(SELECT
ar.code_value_name
FROM
sys_code_values_v ar
WHERE
ar.code = 'YES_NO' AND
ar.code_value = sdic_report_pkg.get_con_cashflow_adjust_flag(p_cashflow_id => cc.cashflow_id, p_type => 1)
) adjust_flag_n,
cc.full_write_off_date
FROM
con_contract c,
con_contract_cashflow cc,
hls_bp_master m,
exp_employees e
WHERE
c.bp_id_tenant = m.bp_id AND
cc.contract_id = c.contract_id AND
c.data_class = 'NORMAL' AND
c.contract_status IN ('INCEPT', 'SIGN', 'ET', 'TERMINATE') AND
nvl(c.hn_adjust_review_flag,'N') = 'Y' AND
c.contract_id IN
(SELECT
t.contract_id
FROM
csh_write_off t
WHERE
t.write_off_type = 'PAYMENT_DEBT' AND
NVL(t.reversed_flag, 'N') = 'N' AND
t.times = 0 AND
t.cf_type = 0 AND
t.cf_item = 0
) AND
c.employee_id = e.employee_id(+)
) t1 #WHERE_CLAUSE#
ORDER BY
due_date,
contract_number,
times
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long"/>
<bm:field name="cashflow_id" databaseType="NUMBER" datatype="java.lang.Long"/>
<bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="times" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="due_date" databaseType="DATE" datatype="java.util.Date"/>
<bm:field name="calc_date" databaseType="DATE" datatype="java.util.Date"/>
<bm:field name="due_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="contact_person" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="principal" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="interest" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="cell_phone"/>
<bm:field name="address"/>
<bm:field name="lease_organization_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="lease_organization" databaseType="VARCHAR2" datatype="java.lang.String"/>
<bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long"/>
<bm:field name="ln_user_col_n20" databaseType="NUMBER" datatype="java.lang.Long"/>
<bm:field name="employee_manager"/>
<bm:field name="cf_direction"/>
<bm:field name="write_off_flag"/>
<bm:field name="write_off_flag_desc"/>
<bm:field name="net_interest" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="net_due_amount"/>
<bm:field name="vat_due_amount"/>
<bm:field name="bank_account_id_n"/>
<bm:field name="bank_account_id"/>
<bm:field name="contract_number_substr"/>
<bm:field name="net_principal" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="vat_principal" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="vat_interest" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="email"/>
<bm:field name="contact_person_fm"/>
<bm:field name="cell_phone_fm"/>
<bm:field name="zipcode"/>
<bm:field name="hn_industry_classification"/>
<bm:field name="hn_industry_classification_n"/>
<bm:field name="sum_principal" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="lease_form"/>
<bm:field name="lease_form_n"/>
<bm:field name="bank_account_num"/>
<bm:field name="bank_name"/>
<bm:field name="annual_pay_times"/>
<bm:field name="annual_pay_times_n"/>
<bm:field name="csh_payment_method_n"/>
<bm:field name="net_lease_charge" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="vat_lease_charge" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="penalty_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="adjust_rate_type"/>
<bm:field name="adjust_rate_type_n"/>
<bm:field name="flt_next_adj_date" databaseType="DATE" datatype="java.util.Date"/>
<bm:field name="adjust_flag"/>
<bm:field name="adjust_flag_n"/>
<bm:field name="cf_item_n"/>
<bm:field name="lease_end_date" databaseType="DATE" datatype="java.util.Date"/>
<bm:field name="outstanding_prin_tax_incld" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="outstanding_rental_tax_incld" databaseType="NUMBER" datatype="java.lang.Double"/>
<bm:field name="full_write_off_date" databaseType="DATE" datatype="java.util.Date"/>
</bm:fields>
<bm:query-fields>
<bm:query-field name="contract_number" queryExpression="t1.contract_number like ${@contract_number}"/>
<bm:query-field name="due_date_from" queryExpression="t1.due_date >= to_date(${@due_date_from},'yyyy-mm-dd')"/>
<bm:query-field name="due_date_to" queryExpression="t1.due_date <= to_date(${@due_date_to},'yyyy-mm-dd')"/>
<bm:query-field name="cf_item" queryExpression="t1.cf_item =${@cf_item}"/>
<bm:query-field name="employee_id" queryExpression="t1.employee_id =${@employee_id}"/>
<bm:query-field name="lease_organization" queryExpression="t1.lease_organization =${@lease_organization}"/>
<bm:query-field name="write_off_flag" queryExpression="t1.write_off_flag=${@write_off_flag}"/>
<bm:query-field name="bp_name" queryExpression="t1.bp_name like ${@bp_name}"/>
</bm:query-fields>
<bm:data-filters>
<bm:data-filter enforceOperations="query" expression="t1.cf_direction not in ('NONCASH','OUTFLOW')"/>
<bm:data-filter enforceOperations="query" expression="t1.due_amount >0"/>
</bm:data-filters>
</bm:model>