1
SELECT dr.ad_client_id,
2
dr.ad_org_id,
3
dr.isactive,
4
dr.created,
5
dr.createdby,
6
dr.updated,
7
dr.updatedby,
8
'en_US'::character varying AS ad_language,
9
dr.c_dunningrun_id,
10
dre.c_dunningrunentry_id,
11
dr.dunningdate,
12
dl.printname,
13
dl.note AS documentnote,
14
dre.c_bpartner_id,
15
bp.value AS bpvalue,
16
bp.taxid AS bptaxid,
17
bp.naics,
18
bp.duns,
19
oi.c_location_id AS org_location_id,
20
oi.taxid,
21
dre.salesrep_id,
22
COALESCE(ubp.name, u.name) AS salesrep_name,
23
bpg.greeting AS bpgreeting,
24
bp.name,
25
bp.name2,
26
bpcg.greeting AS bpcontactgreeting,
27
bpc.title,
28
bpc.phone,
29
NULLIF((bpc.name)::text, (bp.name)::text) AS contactname,
30
bpl.c_location_id,
31
bp.referenceno,
32
((COALESCE(l.postal, ''::character varying))::text || (COALESCE(l.postal_add, ''::character varying))::text) AS postal,
33
dre.amt,
34
dre.qty,
35
dre.note,
36
COALESCE(oi.logo_id, ci.logo_id) AS logo_id,
37
dr.c_dunning_id,
38
dr.c_dunninglevel_id AS c_dunningrun_c_dunninglevel_id,
39
dr.description AS c_dunningrun_description,
40
dr.processed,
41
dr.processing,
42
dr.sendit,
43
dre.ad_org_id AS c_dunningrunentry_ad_org_id,
44
dre.ad_user_id,
45
dre.c_bpartner_location_id,
46
dre.c_currency_id,
47
dre.c_dunninglevel_id AS c_dunrunentry_c_dunlevel_id,
48
dre.created AS c_dunningrunentry_created,
49
dre.createdby AS c_dunningrunentry_createdby,
50
dre.isactive AS c_dunningrunentry_isactive,
51
dre.processed AS c_dunningrunentry_processed,
52
dre.updated AS c_dunningrunentry_updated,
53
dre.updatedby AS c_dunningrunentry_updatedby,
54
dl.ad_org_id AS c_dunninglevel_ad_org_id,
55
dl.c_dunning_id AS c_dunninglevel_c_dunning_id,
56
dl.chargefee,
57
dl.chargeinterest,
58
dl.c_paymentterm_id,
59
dl.daysafterdue,
60
dl.daysbetweendunning,
61
dl.description AS c_dunninglevel_description,
62
dl.dunning_printformat_id,
63
dl.feeamt,
64
dl.interestpercent,
65
dl.invoicecollectiontype,
66
dl.isactive AS c_dunninglevel_isactive,
67
dl.issetcreditstop,
68
dl.issetpaymentterm,
69
dl.isshowalldue,
70
dl.isshownotdue,
71
dl.isstatement,
72
dl.name AS c_dunninglevel_name,
73
bp.acqusitioncost AS c_bpartner_acqusitioncost,
74
bp.actuallifetimevalue AS c_bpartner_actuallifetimevalue,
75
bp.ad_language AS c_bpartner_ad_language,
76
bp.ad_orgbp_id AS c_bpartner_ad_orgbp_id,
77
bp.ad_org_id AS c_bpartner_ad_org_id,
78
bp.bpartner_parent_id AS c_bpartner_bpartner_parent_id,
79
bp.c_bp_group_id AS c_bpartner_c_bp_group_id,
80
bp.c_greeting_id AS c_bpartner_c_greeting_id,
81
bp.c_invoiceschedule_id AS c_bpartner_invoiceschedule_id,
82
bp.c_paymentterm_id AS c_bpartner_c_paymentterm_id,
83
bp.created AS c_bpartner_created,
84
bp.createdby AS c_bpartner_createdby,
85
bp.c_taxgroup_id AS c_bpartner_c_taxgroup_id,
86
bp.deliveryrule AS c_bpartner_deliveryrule,
87
bp.deliveryviarule AS c_bpartner_deliveryviarule,
88
bp.description AS c_bpartner_description,
89
bp.dunninggrace AS c_bpartner_dunninggrace,
90
bp.firstsale AS c_bpartner_firstsale,
91
bp.flatdiscount AS c_bpartner_flatdiscount,
92
bp.freightcostrule AS c_bpartner_freightcostrule,
93
bp.invoicerule AS c_bpartner_invoicerule,
94
bp.isactive AS c_bpartner_isactive,
95
bp.iscustomer AS c_bpartner_iscustomer,
96
bp.isdiscountprinted AS c_bpartner_isdiscountprinted,
97
bp.isemployee AS c_bpartner_isemployee,
98
bp.ismanufacturer AS c_bpartner_ismanufacturer,
99
bp.isonetime AS c_bpartner_isonetime,
100
bp.ispotaxexempt AS c_bpartner_ispotaxexempt,
101
bp.isprospect AS c_bpartner_isprospect,
102
bp.issalesrep AS c_bpartner_issalesrep,
103
bp.issummary AS c_bpartner_issummary,
104
bp.istaxexempt AS c_bpartner_istaxexempt,
105
bp.isvendor AS c_bpartner_isvendor,
106
bp.logo_id AS c_bpartner_logo_id,
107
bp.m_discountschema_id AS c_bpartner_m_discountschema_id,
108
bp.m_pricelist_id AS c_bpartner_m_pricelist_id,
109
bp.naics AS c_bpartner_naics,
110
bp.numberemployees AS c_bpartner_numberemployees,
111
bp.paymentrule AS c_bpartner_paymentrule,
112
bp.paymentrulepo AS c_bpartner_paymentrulepo,
113
bp.po_discountschema_id AS c_bpartnerpo_discountschema_id,
114
bp.po_paymentterm_id AS c_bpartner_po_paymentterm_id,
115
bp.po_pricelist_id AS c_bpartner_po_pricelist_id,
116
bp.poreference AS c_bpartner_poreference,
117
bp.potentiallifetimevalue AS c_bpartner_potentiallifetimev,
118
bp.rating AS c_bpartner_rating,
119
bp.salesrep_id AS c_bpartner_salesrep_id,
120
bp.salesvolume AS c_bpartner_salesvolume,
121
bp.sendemail AS c_bpartner_sendemail,
122
bp.shareofcustomer AS c_bpartner_shareofcustomer,
123
bp.shelflifeminpct AS c_bpartner_shelflifeminpct,
124
bp.so_creditlimit AS c_bpartner_so_creditlimit,
125
bp.socreditstatus AS c_bpartner_socreditstatus,
126
bp.so_creditused AS c_bpartner_so_creditused,
127
bp.so_description AS c_bpartner_so_description,
128
bp.totalopenbalance AS c_bpartner_totalopenbalance,
129
bp.updated AS c_bpartner_updated,
130
bp.updatedby AS c_bpartner_updatedby,
131
bp.url AS c_bpartner_url,
132
bpg.ad_org_id AS c_bpartner_greeting_ad_org_id,
133
bpg.isactive AS c_bpartner_greeting_isactive,
134
bpg.isfirstnameonly AS c_bpartner_greeting_isfirstna,
135
bpg.name AS c_bpartner_greeting_name,
136
bpl.ad_org_id AS c_bpartner_location_ad_org_id,
137
bpl.created AS c_bpartner_location_created,
138
bpl.createdby AS c_bpartner_location_createdby,
139
bpl.c_salesregion_id,
140
bpl.fax AS c_bpartner_location_fax,
141
bpl.isactive AS c_bpartner_location_isactive,
142
bpl.isbillto,
143
bpl.isdn,
144
bpl.ispayfrom,
145
bpl.isremitto,
146
bpl.isshipto,
147
bpl.name AS c_bpartner_location_name,
148
bpl.phone AS c_bpartner_location_phone,
149
bpl.phone2 AS c_bpartner_location_phone2,
150
bpl.updated AS c_bpartner_location_updated,
151
bpl.updatedby AS c_bpartner_location_updatedby,
152
l.address1,
153
l.address2,
154
l.address3,
155
l.address4,
156
l.ad_org_id AS c_location_ad_org_id,
157
l.c_city_id,
158
l.c_country_id,
159
l.city,
160
l.created AS c_location_created,
161
l.createdby AS c_location_createdby,
162
l.c_region_id,
163
l.isactive AS c_location_isactive,
164
l.postal_add,
165
l.regionname,
166
l.updated AS c_location_updated,
167
l.updatedby AS c_location_updatedby,
168
bpc.ad_org_id AS ad_user_ad_org_id,
169
bpc.ad_orgtrx_id AS ad_user_ad_ad_orgtrx_id,
170
bpc.birthday AS ad_user_ad_birthday,
171
bpc.c_bpartner_id AS ad_user_c_bpartner_id,
172
bpc.c_bpartner_location_id AS ad_user_c_bpartner_location_id,
173
bpc.c_greeting_id AS ad_user_c_greeting_id,
174
bpc.comments AS ad_user_comments,
175
bpc.created AS ad_user_created,
176
bpc.createdby AS ad_user_createdby,
177
bpc.description AS ad_user_description,
178
bpc.email AS ad_user_email,
179
bpc.fax AS ad_user_fax,
180
bpc.isactive AS ad_user_isactive,
181
bpc.lastcontact AS ad_user_lastcontact,
182
bpc.lastresult AS ad_user_lastresult,
183
bpc.name AS ad_user_name,
184
bpc.phone2 AS ad_user_phone2,
185
bpc.supervisor_id AS ad_user_supervisor_id,
186
bpc.updated AS ad_user_updated,
187
bpc.updatedby AS ad_user_updatedby,
188
bpc.value AS ad_user_value,
189
bpcg.ad_org_id AS c_user_greeting_ad_org_id,
190
bpcg.isactive AS c_user_greeting_isactive,
191
bpcg.isfirstnameonly AS c_user_greeting_isfirstnameon,
192
bpcg.name AS c_user_greeting_name,
193
oi.ad_org_id AS ad_orginfo_ad_org_id,
194
oi.ad_orgtype_id,
195
oi.c_calendar_id,
196
oi.created AS ad_orginfo_created,
197
oi.createdby AS ad_orginfo_createdby,
198
oi.dropship_warehouse_id,
199
oi.duns AS ad_orginfo_duns,
200
oi.email AS ad_orginfo_email,
201
oi.fax AS ad_orginfo_fax,
202
oi.isactive AS ad_orginfo_isactive,
203
oi.m_warehouse_id,
204
oi.parent_org_id,
205
oi.phone AS ad_orginfo_phone,
206
oi.phone2 AS ad_orginfo_phone2,
207
oi.receiptfootermsg,
208
oi.supervisor_id,
209
oi.updated AS ad_orginfo_updated,
210
oi.updatedby AS ad_orginfo_updatedby,
211
u.ad_org_id AS salesrep_ad_org_id,
212
u.ad_orgtrx_id AS salesrep_ad_ad_orgtrx_id,
213
u.birthday AS salesrep_ad_birthday,
214
u.c_bpartner_id AS salesrep_c_bpartner_id,
215
u.c_bpartner_location_id AS salesrep_c_bp_location_id,
216
u.c_greeting_id AS salesrep_c_greeting_id,
217
u.comments AS salesrep_comments,
218
u.created AS salesrep_created,
219
u.createdby AS salesrep_createdby,
220
u.description AS salesrep_description,
221
u.email AS salesrep_email,
222
u.fax AS salesrep_fax,
223
u.isactive AS salesrep_isactive,
224
u.lastcontact AS salesrep_lastcontact,
225
u.lastresult AS salesrep_lastresult,
226
u.phone2 AS salesrep_phone2,
227
u.supervisor_id AS salesrep_supervisor_id,
228
u.updated AS salesrep_updated,
229
u.updatedby AS salesrep_updatedby,
230
u.value AS salesrep_value,
231
ubp.acqusitioncost AS salesrep_bpartner_acqusitionc,
232
ubp.actuallifetimevalue AS salesrep_bpartner_actuallifet,
233
ubp.ad_language AS salesrep_bpartner_ad_language,
234
ubp.ad_orgbp_id AS salesrep_bpartner_ad_orgbp_id,
235
ubp.ad_org_id AS salesrep_bpartner_ad_org_id,
236
ubp.bpartner_parent_id AS salesrep_bpartner_bp_parent_id,
237
ubp.c_bp_group_id AS salesrep_bp_c_bp_group_id,
238
ubp.c_greeting_id AS salesrep_bp_c_greeting_id,
239
ubp.c_invoiceschedule_id AS salesrep_bp_invoiceschedule_id,
240
ubp.c_paymentterm_id AS salesrep_bp_c_paymentterm_id,
241
ubp.created AS salesrep_bpartner_created,
242
ubp.createdby AS salesrep_bpartner_createdby,
243
ubp.c_taxgroup_id AS salesrep_bp_c_taxgroup_id,
244
ubp.deliveryrule AS salesrep_bpartner_deliveryrule,
245
ubp.deliveryviarule AS salesrep_bpartner_deliveryvia,
246
ubp.description AS salesrep_bpartner_description,
247
ubp.dunninggrace AS salesrep_bpartner_dunninggrace,
248
ubp.firstsale AS salesrep_bpartner_firstsale,
249
ubp.flatdiscount AS salesrep_bpartner_flatdiscount,
250
ubp.freightcostrule AS salesrep_bpartner_freightcost,
251
ubp.invoicerule AS salesrep_bpartner_invoicerule,
252
ubp.isactive AS salesrep_bpartner_isactive,
253
ubp.iscustomer AS salesrep_bpartner_iscustomer,
254
ubp.isdiscountprinted AS salesrep_bpartner_isdiscountp,
255
ubp.isemployee AS salesrep_bpartner_isemployee,
256
ubp.ismanufacturer AS salesrep_bpartner_ismanufactu,
257
ubp.isonetime AS salesrep_bpartner_isonetime,
258
ubp.ispotaxexempt AS salesrep_bpartner_ispotaxexem,
259
ubp.isprospect AS salesrep_bpartner_isprospect,
260
ubp.issalesrep AS salesrep_bpartner_issalesrep,
261
ubp.issummary AS salesrep_bpartner_issummary,
262
ubp.istaxexempt AS salesrep_bpartner_istaxexempt,
263
ubp.isvendor AS salesrep_bpartner_isvendor,
264
ubp.logo_id AS salesrep_bpartner_logo_id,
265
ubp.m_discountschema_id AS salesrep_bp_mdiscountschema_id,
266
ubp.m_pricelist_id AS salesrep_bp_m_pricelist_id,
267
ubp.naics AS salesrep_bpartner_naics,
268
ubp.numberemployees AS salesrep_bpartner_numberemplo,
269
ubp.paymentrule AS salesrep_bpartner_paymentrule,
270
ubp.paymentrulepo AS salesrep_bpartner_paymentrupo,
271
ubp.po_discountschema_id AS salesrep_bp_po_discountscm_id,
272
ubp.po_paymentterm_id AS salesrep_bp_po_paymentterm_id,
273
ubp.po_pricelist_id AS salesrep_bp_po_pricelist_id,
274
ubp.poreference AS salesrep_bpartner_poreference,
275
ubp.potentiallifetimevalue AS salesrep_bpartner_potentialli,
276
ubp.rating AS salesrep_bpartner_rating,
277
ubp.salesrep_id AS salesrep_bpartner_salesrep_id,
278
ubp.salesvolume AS salesrep_bpartner_salesvolume,
279
ubp.sendemail AS salesrep_bpartner_sendemail,
280
ubp.shareofcustomer AS salesrep_bpartner_shareofcust,
281
ubp.shelflifeminpct AS salesrep_bpartner_shelflifemi,
282
ubp.so_creditlimit AS salesrep_bpartner_so_creditli,
283
ubp.socreditstatus AS salesrep_bpartner_socreditsta,
284
ubp.so_creditused AS salesrep_bpartner_so_creditus,
285
ubp.so_description AS salesrep_bpartner_so_descript,
286
ubp.totalopenbalance AS salesrep_bpartner_totalopenba,
287
ubp.updated AS salesrep_bpartner_updated,
288
ubp.updatedby AS salesrep_bpartner_updatedby,
289
ubp.url AS salesrep_bpartner_url
290
FROM ((((((((((((c_dunningrun dr
291
JOIN c_dunningrunentry dre ON ((dr.c_dunningrun_id = dre.c_dunningrun_id)))
292
JOIN c_dunninglevel dl ON ((dre.c_dunninglevel_id = dl.c_dunninglevel_id)))
293
JOIN c_bpartner bp ON ((dre.c_bpartner_id = bp.c_bpartner_id)))
294
LEFT JOIN c_greeting bpg ON ((bp.c_greeting_id = bpg.c_greeting_id)))
295
JOIN c_bpartner_location bpl ON ((dre.c_bpartner_location_id = bpl.c_bpartner_location_id)))
296
JOIN c_location l ON ((bpl.c_location_id = l.c_location_id)))
297
LEFT JOIN ad_user bpc ON ((dre.ad_user_id = bpc.ad_user_id)))
298
LEFT JOIN c_greeting bpcg ON ((bpc.c_greeting_id = bpcg.c_greeting_id)))
299
JOIN ad_orginfo oi ON ((dr.ad_org_id = oi.ad_org_id)))
300
JOIN ad_clientinfo ci ON ((dr.ad_client_id = ci.ad_client_id)))
301
LEFT JOIN ad_user u ON ((dre.salesrep_id = u.ad_user_id)))
302
LEFT JOIN c_bpartner ubp ON ((u.c_bpartner_id = ubp.c_bpartner_id)));