1
SELECT p.ad_client_id,
2
p.ad_org_id,
3
p.isactive,
4
p.created,
5
p.createdby,
6
p.updated,
7
p.updatedby,
8
'en_US'::character varying AS ad_language,
9
p.c_project_id,
10
p.value,
11
p.name AS projectname,
12
p.description,
13
p.note,
14
p.issummary,
15
p.projectcategory,
16
oi.c_location_id AS org_location_id,
17
oi.taxid,
18
p.c_projecttype_id,
19
pjt.name AS projecttypename,
20
p.c_phase_id,
21
pjp.name AS projectphasename,
22
p.salesrep_id,
23
COALESCE(ubp.name, u.name) AS salesrep_name,
24
p.c_bpartner_id,
25
bp.value AS bpvalue,
26
bp.taxid AS bptaxid,
27
bp.naics,
28
bp.duns,
29
bpg.greeting AS bpgreeting,
30
bp.name,
31
bp.name2,
32
bpcg.greeting AS bpcontactgreeting,
33
bpc.title,
34
bpc.phone,
35
NULLIF((bpc.name)::text, (bp.name)::text) AS contactname,
36
bpl.c_location_id,
37
bp.referenceno,
38
pt.name AS paymentterm,
39
pt.documentnote AS paymenttermnote,
40
p.poreference,
41
p.c_currency_id,
42
p.m_pricelist_version_id,
43
p.c_campaign_id,
44
p.plannedamt,
45
p.plannedqty,
46
p.plannedmarginamt,
47
p.invoicedamt,
48
p.invoicedqty,
49
p.projectbalanceamt,
50
p.iscommitment,
51
p.committedamt,
52
p.committedqty,
53
p.datecontract,
54
p.datefinish,
55
p.iscommitceiling,
56
p.m_warehouse_id,
57
COALESCE(oi.logo_id, ci.logo_id) AS logo_id,
58
p.ad_user_id,
59
p.c_bpartner_location_id,
60
p.copyfrom,
61
p.c_paymentterm_id AS c_project_c_paymentterm_id,
62
p.generateto,
63
p.processed AS c_project_processed,
64
p.processing AS c_project_processing,
65
p.projectlinelevel,
66
p.projinvoicerule,
67
bp.acqusitioncost AS c_bp_acqusitioncost,
68
bp.actuallifetimevalue AS c_bp_actuallifetimevalue,
69
bp.ad_language AS c_bp_ad_language,
70
bp.ad_orgbp_id AS c_bp_ad_orgbp_id,
71
bp.ad_org_id AS c_bp_ad_org_id,
72
bp.bpartner_parent_id AS c_bp_bpartner_parent_id,
73
bp.c_bp_group_id AS c_bp_c_bp_group_id,
74
bp.c_dunning_id AS c_bp_c_dunning_id,
75
bp.c_greeting_id AS c_bp_c_greeting_id,
76
bp.c_invoiceschedule_id AS c_bp_c_invoiceschedule_id,
77
bp.c_paymentterm_id AS c_bp_c_paymentterm_id,
78
bp.created AS c_bp_created,
79
bp.createdby AS c_bp_createdby,
80
bp.c_taxgroup_id AS c_bp_c_taxgroup_id,
81
bp.deliveryrule AS c_bp_deliveryrule,
82
bp.deliveryviarule AS c_bp_deliveryviarule,
83
bp.description AS c_bp_description,
84
bp.dunninggrace AS c_bp_dunninggrace,
85
bp.firstsale AS c_bp_firstsale,
86
bp.flatdiscount AS c_bp_flatdiscount,
87
bp.freightcostrule AS c_bp_freightcostrule,
88
bp.invoicerule AS c_bp_invoicerule,
89
bp.isactive AS c_bp_isactive,
90
bp.iscustomer AS c_bp_iscustomer,
91
bp.isdiscountprinted AS c_bp_isdiscountprinted,
92
bp.isemployee AS c_bp_isemployee,
93
bp.ismanufacturer AS c_bp_ismanufacturer,
94
bp.isonetime AS c_bp_isonetime,
95
bp.ispotaxexempt AS c_bp_ispotaxexempt,
96
bp.isprospect AS c_bp_isprospect,
97
bp.issalesrep AS c_bp_issalesrep,
98
bp.issummary AS c_bp_issummary,
99
bp.istaxexempt AS c_bp_istaxexempt,
100
bp.isvendor AS c_bp_isvendor,
101
bp.logo_id AS c_bp_logo_id,
102
bp.m_discountschema_id AS c_bp_m_discountschema_id,
103
bp.m_pricelist_id AS c_bp_m_pricelist_id,
104
bp.numberemployees AS c_bp_numberemployees,
105
bp.paymentrule AS c_bp_paymentrule,
106
bp.paymentrulepo AS c_bp_paymentrulepo,
107
bp.po_discountschema_id AS c_bp_po_discountschema_id,
108
bp.po_paymentterm_id AS c_bp_po_paymentterm_id,
109
bp.po_pricelist_id AS c_bp_po_pricelist_id,
110
bp.poreference AS c_bp_poreference,
111
bp.potentiallifetimevalue AS c_bp_potentiallifetimevalue,
112
bp.rating AS c_bp_rating,
113
bp.salesrep_id AS c_bp_salesrep_id,
114
bp.salesvolume AS c_bp_salesvolume,
115
bp.sendemail AS c_bp_sendemail,
116
bp.shareofcustomer AS c_bp_shareofcustomer,
117
bp.shelflifeminpct AS c_bp_shelflifeminpct,
118
bp.so_creditlimit AS c_bp_so_creditlimit,
119
bp.socreditstatus AS c_bp_socreditstatus,
120
bp.so_creditused AS c_bp_so_creditused,
121
bp.so_description AS c_bp_so_description,
122
bp.totalopenbalance AS c_bp_totalopenbalance,
123
bp.updated AS c_bp_updated,
124
bp.updatedby AS c_bp_updatedby,
125
bp.url AS c_bp_url,
126
oi.ad_org_id AS ad_orginfo_ad_org_id,
127
oi.ad_orgtype_id,
128
oi.c_calendar_id,
129
oi.created AS ad_orginfo_created,
130
oi.createdby AS ad_orginfo_createdby,
131
oi.dropship_warehouse_id,
132
oi.duns AS ad_orginfo_duns,
133
oi.email AS ad_orginfo_email,
134
oi.fax AS ad_orginfo_fax,
135
oi.isactive AS ad_orginfo_isactive,
136
oi.m_warehouse_id AS ad_orginfo_m_warehouse_id,
137
oi.parent_org_id,
138
oi.phone AS ad_orginfo_phone,
139
oi.phone2 AS ad_orginfo_phone2,
140
oi.receiptfootermsg,
141
oi.supervisor_id,
142
oi.updated AS ad_orginfo_updated,
143
oi.updatedby AS ad_orginfo_updatedby,
144
pjt.ad_org_id AS c_projecttype_ad_org_id,
145
pjt.description AS c_projecttype_description,
146
pjt.help AS c_projecttype_help,
147
pjt.isactive AS c_projecttype_isactive,
148
pjt.projectcategory AS c_projecttype_projectcategory,
149
pjp.ad_org_id AS c_phase_ad_org_id,
150
pjp.c_phase_id AS c_phase_c_phase_id,
151
pjp.c_projecttype_id AS c_phase_c_projecttype_id,
152
pjp.description AS c_phase_description,
153
pjp.help AS c_phase_help,
154
pjp.isactive AS c_phase_isactive,
155
pjp.m_product_id AS c_phase_m_product_id,
156
pjp.seqno AS c_phase_seqno,
157
pjp.standardqty,
158
u.ad_org_id AS salesrep_ad_org_id,
159
u.ad_orgtrx_id AS salesrep_ad_orgtrx_id,
160
u.birthday AS salesrep_ad_birthday,
161
u.c_bpartner_id AS salesrep_c_bpartner_id,
162
u.c_bpartner_location_id AS salesrep_c_bp_location_id,
163
u.c_greeting_id AS salesrep_c_greeting_id,
164
u.comments AS salesrep_comments,
165
u.created AS salesrep_created,
166
u.createdby AS salesrep_createdby,
167
u.description AS salesrep_description,
168
u.email AS salesrep_email,
169
u.fax AS salesrep_fax,
170
u.isactive AS salesrep_isactive,
171
u.lastcontact AS salesrep_lastcontact,
172
u.lastresult AS salesrep_lastresult,
173
u.phone AS salesrep_phone,
174
u.phone2 AS salesrep_phone2,
175
u.supervisor_id AS salesrep_supervisor_id,
176
u.title AS salesrep_title,
177
u.updated AS salesrep_updated,
178
u.updatedby AS salesrep_updatedby,
179
u.value AS salesrep_value,
180
ubp.acqusitioncost AS salesrep_bp_acqusitioncost,
181
ubp.actuallifetimevalue AS salesrep_bp_actuallifevalue,
182
ubp.ad_language AS salesrep_bp_ad_language,
183
ubp.ad_orgbp_id AS salesrep_bp_ad_orgbp_id,
184
ubp.ad_org_id AS salesrep_bp_ad_org_id,
185
ubp.bpartner_parent_id AS salesrep_bp_bpartner_parent_id,
186
ubp.c_bp_group_id AS salesrep_bp_c_bp_group_id,
187
ubp.c_dunning_id AS salesrep_bp_c_dunning_id,
188
ubp.c_greeting_id AS salesrep_bp_c_greeting_id,
189
ubp.c_invoiceschedule_id AS salesrep_bp_c_invoicesched_id,
190
ubp.c_paymentterm_id AS salesrep_bp_c_paymentterm_id,
191
ubp.created AS salesrep_bp_created,
192
ubp.createdby AS salesrep_bp_createdby,
193
ubp.c_taxgroup_id AS salesrep_bp_c_taxgroup_id,
194
ubp.deliveryrule AS salesrep_bp_deliveryrule,
195
ubp.deliveryviarule AS salesrep_bp_deliveryviarule,
196
ubp.description AS salesrep_bp_description,
197
ubp.dunninggrace AS salesrep_bp_dunninggrace,
198
ubp.duns AS salesrep_bp_duns,
199
ubp.firstsale AS salesrep_bp_firstsale,
200
ubp.flatdiscount AS salesrep_bp_flatdiscount,
201
ubp.freightcostrule AS salesrep_bp_freightcostrule,
202
ubp.invoicerule AS salesrep_bp_invoicerule,
203
ubp.isactive AS salesrep_bp_isactive,
204
ubp.iscustomer AS salesrep_bp_iscustomer,
205
ubp.isdiscountprinted AS salesrep_bp_isdiscountprinted,
206
ubp.isemployee AS salesrep_bp_isemployee,
207
ubp.ismanufacturer AS salesrep_bp_ismanufacturer,
208
ubp.isonetime AS salesrep_bp_isonetime,
209
ubp.ispotaxexempt AS salesrep_bp_ispotaxexempt,
210
ubp.isprospect AS salesrep_bp_isprospect,
211
ubp.issalesrep AS salesrep_bp_issalesrep,
212
ubp.issummary AS salesrep_bp_issummary,
213
ubp.istaxexempt AS salesrep_bp_istaxexempt,
214
ubp.isvendor AS salesrep_bp_isvendor,
215
ubp.logo_id AS salesrep_bp_logo_id,
216
ubp.m_discountschema_id AS salesrep_bp_m_discountschm_id,
217
ubp.m_pricelist_id AS salesrep_bp_m_pricelist_id,
218
ubp.naics AS salesrep_bp_naics,
219
ubp.name2 AS salesrep_bp_name2,
220
ubp.numberemployees AS salesrep_bp_numberemployees,
221
ubp.paymentrule AS salesrep_bp_paymentrule,
222
ubp.paymentrulepo AS salesrep_bp_paymentrulepo,
223
ubp.po_discountschema_id AS salesrep_bp_po_discountschm_id,
224
ubp.po_paymentterm_id AS salesrep_bp_po_paymentterm_id,
225
ubp.po_pricelist_id AS salesrep_bp_po_pricelist_id,
226
ubp.poreference AS salesrep_bp_poreference,
227
ubp.potentiallifetimevalue AS salesrep_bp_potentiallifevalue,
228
ubp.rating AS salesrep_bp_rating,
229
ubp.referenceno AS salesrep_bp_referenceno,
230
ubp.salesrep_id AS salesrep_bp_salesrep_id,
231
ubp.salesvolume AS salesrep_bp_salesvolume,
232
ubp.sendemail AS salesrep_bp_sendemail,
233
ubp.shareofcustomer AS salesrep_bp_shareofcustomer,
234
ubp.shelflifeminpct AS salesrep_bp_shelflifeminpct,
235
ubp.so_creditlimit AS salesrep_bp_so_creditlimit,
236
ubp.socreditstatus AS salesrep_bp_socreditstatus,
237
ubp.so_creditused AS salesrep_bp_so_creditused,
238
ubp.so_description AS salesrep_bp_so_description,
239
ubp.taxid AS salesrep_bp_taxid,
240
ubp.totalopenbalance AS salesrep_bp_totalopenbalance,
241
ubp.updated AS salesrep_bp_updated,
242
ubp.updatedby AS salesrep_bp_updatedby,
243
ubp.url AS salesrep_bp_url,
244
ubp.value AS salesrep_bp_value,
245
bpg.ad_org_id AS c_greeting_ad_org_id,
246
bpg.isactive AS c_greeting_isactive,
247
bpg.isfirstnameonly,
248
bpg.name AS c_greeting_name,
249
bpc.ad_org_id AS ad_user_ad_org_id,
250
bpc.ad_orgtrx_id AS ad_user_ad_orgtrx_id,
251
bpc.birthday AS ad_user_ad_birthday,
252
bpc.c_bpartner_id AS ad_user_c_bpartner_id,
253
bpc.c_bpartner_location_id AS ad_user_c_bpartner_location_id,
254
bpc.c_greeting_id AS ad_user_c_greeting_id,
255
bpc.comments AS ad_user_comments,
256
bpc.created AS ad_user_created,
257
bpc.createdby AS ad_user_createdby,
258
bpc.description AS ad_user_description,
259
bpc.email AS ad_user_email,
260
bpc.fax AS ad_user_fax,
261
bpc.isactive AS ad_user_isactive,
262
bpc.lastcontact AS ad_user_lastcontact,
263
bpc.lastresult AS ad_user_lastresult,
264
bpc.phone2 AS ad_user_phone2,
265
bpc.supervisor_id AS ad_user_supervisor_id,
266
bpc.updated AS ad_user_updated,
267
bpc.updatedby AS ad_user_updatedby,
268
bpc.value AS ad_user_value,
269
bpcg.ad_org_id AS c_user_greeting_ad_org_id,
270
bpcg.c_greeting_id AS c_user_greeting_c_greeting_id,
271
bpcg.isactive AS c_user_greeting_isactive,
272
bpcg.isfirstnameonly AS c_user_greeting_isfnameonly,
273
bpcg.name AS c_user_greeting_name,
274
bpl.ad_org_id AS c_bp_location_ad_org_id,
275
bpl.c_bpartner_id AS c_bp_location_c_bpartner_id,
276
bpl.created AS c_bp_location_created,
277
bpl.createdby AS c_bp_location_createdby,
278
bpl.c_salesregion_id,
279
bpl.fax AS c_bp_location_fax,
280
bpl.isactive AS c_bp_location_isactive,
281
bpl.isbillto,
282
bpl.isdn,
283
bpl.ispayfrom,
284
bpl.isremitto,
285
bpl.isshipto,
286
bpl.name AS c_bp_location_name,
287
bpl.phone AS c_bp_location_phone,
288
bpl.phone2 AS c_bp_location_phone2,
289
bpl.updated AS c_bp_location_updated,
290
bpl.updatedby AS c_bp_location_updatedby,
291
pt.ad_org_id AS c_paymentterm_ad_org_id,
292
pt.afterdelivery,
293
pt.c_paymentterm_id AS c_paymentterm_c_paymentterm_id,
294
pt.description AS c_paymentterm_description,
295
pt.discount,
296
pt.discount2,
297
pt.discountdays,
298
pt.discountdays2,
299
pt.fixmonthcutoff,
300
pt.fixmonthday,
301
pt.fixmonthoffset,
302
pt.gracedays,
303
pt.isactive AS c_paymentterm_isactive,
304
pt.isdefault,
305
pt.isduefixed,
306
pt.isnextbusinessday,
307
pt.isvalid,
308
pt.netday,
309
pt.netdays,
310
pt.paymenttermusage,
311
pt.value AS c_paymentterm_value
312
FROM ((((((((((((c_project p
313
LEFT JOIN c_bpartner bp ON ((p.c_bpartner_id = bp.c_bpartner_id)))
314
JOIN ad_orginfo oi ON ((p.ad_org_id = oi.ad_org_id)))
315
JOIN ad_clientinfo ci ON ((p.ad_client_id = ci.ad_client_id)))
316
LEFT JOIN c_projecttype pjt ON ((p.c_projecttype_id = pjt.c_projecttype_id)))
317
LEFT JOIN c_phase pjp ON ((p.c_phase_id = pjp.c_phase_id)))
318
LEFT JOIN ad_user u ON ((p.salesrep_id = u.ad_user_id)))
319
LEFT JOIN c_bpartner ubp ON ((u.c_bpartner_id = ubp.c_bpartner_id)))
320
LEFT JOIN c_greeting bpg ON ((bp.c_greeting_id = bpg.c_greeting_id)))
321
LEFT JOIN ad_user bpc ON ((p.ad_user_id = bpc.ad_user_id)))
322
LEFT JOIN c_greeting bpcg ON ((bpc.c_greeting_id = bpcg.c_greeting_id)))
323
LEFT JOIN c_bpartner_location bpl ON ((p.c_bpartner_location_id = bpl.c_bpartner_location_id)))
324
LEFT JOIN c_paymentterm pt ON ((p.c_paymentterm_id = pt.c_paymentterm_id)));